Dan Gohman
2008-Jul-02 23:54 UTC
[LLVMdev] Plans considering first class structs and multiple return values
Hello, The basic infrastructure is in place. You can create first-class structs/arrays using sequences of insertvalue. For example, this: %t0 = insertvalue { i32, i32 } undef, i32 %a, 0 %t1 = insertvalue { i32, i32 } %t0, i32 %b, 1 creates the value with %a and %b as member values. Other ways to produce aggregate values are loads, function arguments, function return values, and literal constants. It's all pretty new and hasn't seen much exposure, so one of the things it needs right now is for people to try it out and see how it goes. There is work yet to be done in several of the optimization components. And codegen can't yet handle aggregate return values larger than what fits in designated return value registers. I'm planning to have LLVM auto-upgrade the multiple-return-value constructs that exist in LLVM 2.3, which should give it quite a bit of exposure, though that probably won't happen for a while. And while I'm here, I want to emphasize that this feature does not completely solve the problem of C-oriented ABI-compliant passing/returning of structs. That's a complicated problem, and unfortunately it is beyond the immediate scope of this feature. Dan On Jul 2, 2008, at 3:00 PM, Marc de Kruijf wrote:> Hi, I'm really interested in this effort. What is its status? Is any > of it in svn yet? (I only see the insert/extract value instructions > so far... nothing w.r.t. creating a first-class struct/array). Can I > do anything to help? > > Marc
Marc de Kruijf
2008-Jul-03 01:37 UTC
[LLVMdev] Plans considering first class structs and multiple return values
> For example, this: > > %t0 = insertvalue { i32, i32 } undef, i32 %a, 0 > %t1 = insertvalue { i32, i32 } %t0, i32 %b, 1 > > creates the value with %a and %b as member values.Is there anyway to do it using the C++ API? It seems I need an instance of the aggregate type to pass into InsertValueInst::Create(). What is the API equivalent of "undef"? Marc On Wed, Jul 2, 2008 at 6:54 PM, Dan Gohman <gohman at apple.com> wrote:> Hello, > > The basic infrastructure is in place. You can create first-class > structs/arrays using sequences of insertvalue. > > For example, this: > > %t0 = insertvalue { i32, i32 } undef, i32 %a, 0 > %t1 = insertvalue { i32, i32 } %t0, i32 %b, 1 > > creates the value with %a and %b as member values. Other ways to > produce aggregate values are loads, function arguments, function > return values, and literal constants. > > It's all pretty new and hasn't seen much exposure, so one of > the things it needs right now is for people to try it out and > see how it goes. > > There is work yet to be done in several of the optimization > components. And codegen can't yet handle aggregate return > values larger than what fits in designated return value > registers. I'm planning to have LLVM auto-upgrade the > multiple-return-value constructs that exist in LLVM 2.3, > which should give it quite a bit of exposure, though that > probably won't happen for a while. > > And while I'm here, I want to emphasize that this feature does > not completely solve the problem of C-oriented ABI-compliant > passing/returning of structs. That's a complicated problem, and > unfortunately it is beyond the immediate scope of this feature. > > Dan > > On Jul 2, 2008, at 3:00 PM, Marc de Kruijf wrote: > >> Hi, I'm really interested in this effort. What is its status? Is any >> of it in svn yet? (I only see the insert/extract value instructions >> so far... nothing w.r.t. creating a first-class struct/array). Can I >> do anything to help? >> >> Marc > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Eli Friedman
2008-Jul-03 01:55 UTC
[LLVMdev] Plans considering first class structs and multiple return values
On Wed, Jul 2, 2008 at 6:37 PM, Marc de Kruijf <dekruijf at cs.wisc.edu> wrote:> What is the API equivalent of "undef"?UndefValue::get(const Type*), in Constants.h. -Eli
Matthijs Kooijman - Inter-Actief
2008-Jul-03 07:37 UTC
[LLVMdev] Plans considering first class structs and multiple return values
Hi Marc, there a few examples of this in the code, have look at BuildSubAggregate in lib/Analysis/ValueTracking.cpp for example (there's quite some code around it and it's recursive, which doesn't make this the best example, but it should help). The interesting parts look something like this: Value *Undef = UndefValue::get(IndexedType); Value *T0 = lvm::InsertValueInst::Create(To, V, Idxs.begin(), Idxs.end(), "tmp", InsertBefore); Value *T1 = lvm::InsertValueInst::Create(To, V, Idxs2.begin(), Idxs2.end(), "tmp", InsertBefore); Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080703/5895260d/attachment.sig>
Seemingly Similar Threads
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] [patch] Remove getType() overrides from extractvalue and insertvalue
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] CPP API User-level Question: Returning multiple values