Hi, I'm trying to implement structs as first class values. If I assemble ; ModuleID = 't0022.s.bc' target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" target triple = "i386-pc-linux-gnu" %struct.foo = type { i32, i32, i32 } define %struct.foo @main() nounwind { entry: %foo = alloca %struct.foo ; <%struct.foo*> [#uses=1] %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] br label %return return: ; preds = %entry %t = load %struct.foo* %foo ; <%struct.foo> [#uses=1] ret %struct.foo %t } It assembles without complaint. If I do llc I get an assert: x86: Return operand #2 has unhandled type i32 llc[0x8b5981e] ... arm: llc: /home/rich/llvm-trunk-new/lib/VMCore/ValueTypes.cpp:109: static llvm::MVT llvm::MVT::getMVT(const llvm::Type*, bool): Assertion `0 && "Unknown type!"' failed. ... My questions are: Is this supposed to work? (I understand it may be a work in progress.) Is the LLVM well formed at the source level? -Rich
On Jul 20, 2008, at 6:25 AM, Richard Pennington wrote:> Hi, > > I'm trying to implement structs as first class values. If I assemble > > It assembles without complaint.Yep, the code looks fine.> If I do llc I get an assert: > > > My questions are: > > Is this supposed to work? (I understand it may be a work in > progress.)Yes, that is supposed to work in theory. In practice, most targets only support returning up to two values in registers. Eventually, we want the code generator to support returning excess return values on the stack, but we don't have that code yet.> Is the LLVM well formed at the source level?Yep, this is just a limitation of the current code generators. Prior to first-class aggregate support, we did have MRV support, which has the same limitation so far. -Chris
Chris Lattner wrote:> On Jul 20, 2008, at 6:25 AM, Richard Pennington wrote: > Yes, that is supposed to work in theory. In practice, most targets > only support returning up to two values in registers. Eventually, we > want the code generator to support returning excess return values on > the stack, but we don't have that code yet.Thanks for the info. Is the intention to implement this in an ABI compatible manner? That is, pass the address to put the return value as a hidden first parameter, for example? -Rich
Seemingly Similar Threads
- [LLVMdev] Structs as first class values.
- [LLVMdev] Structs as first class values.
- [LLVMdev] Structs as first class values.
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] Plans considering first class structs and multiple return values