annotate gen/functions.cpp @ 1151:3cf0066e6faf

- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM. - Eliminated the DLRValue DValue. - Implemented proactive handling of l-value CastExpS. - Minor tweak in runtime memory.d .
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Sat, 28 Mar 2009 05:00:43 +0100
parents 5ebe8224988b
children 521dd1626d76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
1 #include "gen/llvm.h"
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 258
diff changeset
2 #include "llvm/Support/CFG.h"
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
3 #include "llvm/Intrinsics.h"
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
4
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
5 #include "mtype.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
6 #include "aggregate.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
7 #include "init.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
8 #include "declaration.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
9 #include "template.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
10 #include "module.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
11 #include "statement.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
12
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
13 #include "gen/irstate.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
14 #include "gen/tollvm.h"
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
15 #include "gen/llvmhelpers.h"
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
16 #include "gen/runtime.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
17 #include "gen/arrays.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
18 #include "gen/logger.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
19 #include "gen/functions.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
20 #include "gen/todebug.h"
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
21 #include "gen/classes.h"
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
22 #include "gen/dvalue.h"
988
2667e3a145be - Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 958
diff changeset
23 #include "gen/abi.h"
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
24
1117
4c20fcc4252b Fun with parameter attributes: For several of the "synthetic" parameters added
Frits van Bommel <fvbommel wxs.nl>
parents: 1072
diff changeset
25 using namespace llvm::Attribute;
4c20fcc4252b Fun with parameter attributes: For several of the "synthetic" parameters added
Frits van Bommel <fvbommel wxs.nl>
parents: 1072
diff changeset
26
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
27 const llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, bool ismain)
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
28 {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
29 // already built ?
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
30 if (type->ir.type != NULL) {
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
31 //assert(f->fty != NULL);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
32 return llvm::cast<llvm::FunctionType>(type->ir.type->get());
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
33 }
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
34
1047
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
35 if (Logger::enabled())
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
36 Logger::println("DtoFunctionType(%s)", type->toChars());
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
37 LOG_SCOPE
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
38 // sanity check
435
74101be2a553 Added type param to DVarValue as DMD sometimes overrides the type of the VarDeclaration.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 428
diff changeset
39 assert(type->ty == Tfunction);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
40 TypeFunction* f = (TypeFunction*)type;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
41
1072
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
42 if (f->linkage != LINKintrinsic) {
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
43 // Tell the ABI we're resolving a new function type
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
44 gABI->newFunctionType(f);
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
45 }
1047
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
46
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
47 // start new ir funcTy
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
48 f->fty.reset();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
49
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
50 // llvm idx counter
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
51 size_t lidx = 0;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
52
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
53 // main needs a little special handling
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
54 if (ismain)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
55 {
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
56 f->fty.ret = new IrFuncTyArg(Type::tint32, false);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
57 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
58 // sane return value
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
59 else
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
60 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
61 Type* rt = f->next;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
62 unsigned a = 0;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
63 // sret return
1072
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
64 if (f->linkage != LINKintrinsic)
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
65 if (gABI->returnInArg(f))
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
66 {
1117
4c20fcc4252b Fun with parameter attributes: For several of the "synthetic" parameters added
Frits van Bommel <fvbommel wxs.nl>
parents: 1072
diff changeset
67 f->fty.arg_sret = new IrFuncTyArg(rt, true, StructRet | NoAlias | NoCapture);
1072
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
68 rt = Type::tvoid;
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
69 lidx++;
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
70 }
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
71 // sext/zext return
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
72 else if (unsigned se = DtoShouldExtend(rt))
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
73 {
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
74 a = se;
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
75 }
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
76 f->fty.ret = new IrFuncTyArg(rt, false, a);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
77 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
78 lidx++;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
79
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
80 // member functions
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
81 if (thistype)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
82 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
83 bool toref = (thistype->toBasetype()->ty == Tstruct);
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
84 f->fty.arg_this = new IrFuncTyArg(thistype, toref);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
85 lidx++;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
86 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
87
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
88 // and nested functions
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
89 else if (nesttype)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
90 {
1117
4c20fcc4252b Fun with parameter attributes: For several of the "synthetic" parameters added
Frits van Bommel <fvbommel wxs.nl>
parents: 1072
diff changeset
91 f->fty.arg_nest = new IrFuncTyArg(nesttype, false, NoAlias | NoCapture);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
92 lidx++;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
93 }
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
94
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
95 // vararg functions are special too
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
96 if (f->varargs)
234
9760f54af0b7 [svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents: 225
diff changeset
97 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
98 if (f->linkage == LINKd)
234
9760f54af0b7 [svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents: 225
diff changeset
99 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
100 // d style with hidden args
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
101 // 2 (array) is handled by the frontend
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
102 if (f->varargs == 1)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
103 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
104 // _arguments
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
105 f->fty.arg_arguments = new IrFuncTyArg(Type::typeinfo->type->arrayOf(), false);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
106 lidx++;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
107 // _argptr
1117
4c20fcc4252b Fun with parameter attributes: For several of the "synthetic" parameters added
Frits van Bommel <fvbommel wxs.nl>
parents: 1072
diff changeset
108 f->fty.arg_argptr = new IrFuncTyArg(Type::tvoid->pointerTo(), false, NoAlias | NoCapture);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
109 lidx++;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
110 }
234
9760f54af0b7 [svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents: 225
diff changeset
111 }
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
112 else if (f->linkage == LINKc)
988
2667e3a145be - Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 958
diff changeset
113 {
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
114 f->fty.c_vararg = true;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
115 }
988
2667e3a145be - Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 958
diff changeset
116 else
2667e3a145be - Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 958
diff changeset
117 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
118 type->error(0, "invalid linkage for variadic function");
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
119 fatal();
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
120 }
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
121 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
122
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
123 // if this _Dmain() doesn't have an argument, we force it to have one
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
124 int nargs = Argument::dim(f->parameters);
930
7985bb036db4 Follow the D ABI and pass the last arg in a register if it is a struct that fits.
Christian Kamm <kamm incasoftware de>
parents: 920
diff changeset
125
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
126 if (ismain && nargs == 0)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
127 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
128 Type* mainargs = Type::tchar->arrayOf()->arrayOf();
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
129 f->fty.args.push_back(new IrFuncTyArg(mainargs, false));
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
130 lidx++;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
131 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
132 // add explicit parameters
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
133 else for (int i = 0; i < nargs; i++)
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
134 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
135 // get argument
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
136 Argument* arg = Argument::getNth(f->parameters, i);
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
137
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
138 // reference semantics? ref, out and static arrays are
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
139 bool byref = (arg->storageClass & (STCref|STCout)) || (arg->type->toBasetype()->ty == Tsarray);
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
140
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
141 Type* argtype = arg->type;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
142 unsigned a = 0;
585
fbb1a366cfbc Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 546
diff changeset
143
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
144 // handle lazy args
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
145 if (arg->storageClass & STClazy)
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
146 {
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
147 Logger::println("lazy param");
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
148 TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd);
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
149 TypeDelegate *ltd = new TypeDelegate(ltf);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
150 argtype = ltd;
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
151 }
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
152 // byval
1072
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
153 else if (f->linkage != LINKintrinsic
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
154 && gABI->passByVal(argtype))
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
155 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
156 if (!byref) a |= llvm::Attribute::ByVal;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
157 byref = true;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
158 }
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
159 // sext/zext
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
160 else if (!byref)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
161 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
162 a |= DtoShouldExtend(argtype);
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
163 }
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
164
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
165 f->fty.args.push_back(new IrFuncTyArg(argtype, byref, a));
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
166 lidx++;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
167 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
168
1072
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
169 if (f->linkage != LINKintrinsic) {
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
170 // let the abi rewrite the types as necesary
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
171 gABI->rewriteFunctionType(f);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
172
1072
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
173 // Tell the ABI we're done with this function type
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
174 gABI->doneWithFunctionType();
802d508f66f1 Ignore the ABI some more for intrinsics
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
175 }
1047
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
176
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
177 // build the function type
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
178 std::vector<const LLType*> argtypes;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
179 argtypes.reserve(lidx);
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
180
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
181 if (f->fty.arg_sret) argtypes.push_back(f->fty.arg_sret->ltype);
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
182 if (f->fty.arg_this) argtypes.push_back(f->fty.arg_this->ltype);
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
183 if (f->fty.arg_nest) argtypes.push_back(f->fty.arg_nest->ltype);
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
184 if (f->fty.arg_arguments) argtypes.push_back(f->fty.arg_arguments->ltype);
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
185 if (f->fty.arg_argptr) argtypes.push_back(f->fty.arg_argptr->ltype);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
186
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
187 size_t beg = argtypes.size();
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
188 size_t nargs2 = f->fty.args.size();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
189 for (size_t i = 0; i < nargs2; i++)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
190 {
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
191 argtypes.push_back(f->fty.args[i]->ltype);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
192 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
193
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
194 // reverse params?
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
195 if (f->fty.reverseParams && nargs2 > 1)
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
196 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
197 std::reverse(argtypes.begin() + beg, argtypes.end());
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
198 }
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
199
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
200 llvm::FunctionType* functype = llvm::FunctionType::get(f->fty.ret->ltype, argtypes, f->fty.c_vararg);
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 215
diff changeset
201 f->ir.type = new llvm::PATypeHolder(functype);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
202
1047
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
203 Logger::cout() << "Final function type: " << *functype << "\n";
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
204
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
205 return functype;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
206 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
207
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
208 //////////////////////////////////////////////////////////////////////////////////////////
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
209
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
210 static const llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl)
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
211 {
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
212 // type has already been resolved
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
213 if (fdecl->type->ir.type != 0) {
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
214 return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
215 }
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
216
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
217 TypeFunction* f = (TypeFunction*)fdecl->type;
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
218 const llvm::FunctionType* fty = 0;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
219
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
220 // create new ir funcTy
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
221 f->fty.reset();
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
222 f->fty.ret = new IrFuncTyArg(Type::tvoid, false);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
223
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
224 f->fty.args.push_back(new IrFuncTyArg(Type::tvoid->pointerTo(), false));
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
225
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
226 if (fdecl->llvmInternal == LLVMva_start)
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
227 fty = GET_INTRINSIC_DECL(vastart)->getFunctionType();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
228 else if (fdecl->llvmInternal == LLVMva_copy) {
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
229 fty = GET_INTRINSIC_DECL(vacopy)->getFunctionType();
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
230 f->fty.args.push_back(new IrFuncTyArg(Type::tvoid->pointerTo(), false));
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
231 }
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
232 else if (fdecl->llvmInternal == LLVMva_end)
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
233 fty = GET_INTRINSIC_DECL(vaend)->getFunctionType();
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
234 assert(fty);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
235
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
236 f->ir.type = new llvm::PATypeHolder(fty);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
237 return fty;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
238 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
239
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
240 //////////////////////////////////////////////////////////////////////////////////////////
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
241
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
242 const llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
243 {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
244 // type has already been resolved
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
245 if (fdecl->type->ir.type != 0)
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
246 return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
247
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
248 // handle for C vararg intrinsics
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
249 if (fdecl->isVaIntrinsic())
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
250 return DtoVaFunctionType(fdecl);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
251
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
252 Type *dthis=0, *dnest=0;
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
253
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
254 if (fdecl->needThis()) {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
255 if (AggregateDeclaration* ad = fdecl->isMember2()) {
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
256 Logger::println("isMember = this is: %s", ad->type->toChars());
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
257 dthis = ad->type;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
258 const LLType* thisty = DtoType(dthis);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 109
diff changeset
259 //Logger::cout() << "this llvm type: " << *thisty << '\n';
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
260 if (isaStruct(thisty) || (!gIR->structs.empty() && thisty == gIR->topstruct()->type->ir.type->get()))
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
261 thisty = getPtrToType(thisty);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
262 }
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
263 else {
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
264 Logger::println("chars: %s type: %s kind: %s", fdecl->toChars(), fdecl->type->toChars(), fdecl->kind());
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
265 assert(0);
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
266 }
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
267 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
268 else if (fdecl->isNested()) {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
269 dnest = Type::tvoid->pointerTo();
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
270 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
271
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
272 const llvm::FunctionType* functype = DtoFunctionType(fdecl->type, dthis, dnest, fdecl->isMain());
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
273
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
274 return functype;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
275 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
276
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
277 //////////////////////////////////////////////////////////////////////////////////////////
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
278
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
279 static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl)
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
280 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
281 TypeFunction* f = (TypeFunction*)fdecl->type->toBasetype();
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
282 const llvm::FunctionType* fty = DtoVaFunctionType(fdecl);
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
283 llvm::Function* func = 0;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
284
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
285 if (fdecl->llvmInternal == LLVMva_start)
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
286 func = GET_INTRINSIC_DECL(vastart);
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
287 else if (fdecl->llvmInternal == LLVMva_copy)
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
288 func = GET_INTRINSIC_DECL(vacopy);
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
289 else if (fdecl->llvmInternal == LLVMva_end)
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
290 func = GET_INTRINSIC_DECL(vaend);
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
291 assert(func);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
292
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
293 fdecl->ir.irFunc->func = func;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
294 return func;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
295 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
296
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
297 //////////////////////////////////////////////////////////////////////////////////////////
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
298
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
299 void DtoResolveFunction(FuncDeclaration* fdecl)
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
300 {
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
301 if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
302 Logger::println("Ignoring unittest %s", fdecl->toPrettyChars());
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
303 return; // ignore declaration completely
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
304 }
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
305
622
26fce59fe80a Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 585
diff changeset
306 //printf("resolve function: %s\n", fdecl->toPrettyChars());
26fce59fe80a Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 585
diff changeset
307
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
308 if (fdecl->parent)
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
309 if (TemplateInstance* tinst = fdecl->parent->isTemplateInstance())
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
310 {
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
311 TemplateDeclaration* tempdecl = tinst->tempdecl;
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
312 if (tempdecl->llvmInternal == LLVMva_arg)
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
313 {
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
314 Logger::println("magic va_arg found");
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
315 fdecl->llvmInternal = LLVMva_arg;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
316 fdecl->ir.resolved = true;
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
317 fdecl->ir.declared = true;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
318 fdecl->ir.initialized = true;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
319 fdecl->ir.defined = true;
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
320 return; // this gets mapped to an instruction so a declaration makes no sence
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
321 }
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
322 else if (tempdecl->llvmInternal == LLVMva_start)
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
323 {
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
324 Logger::println("magic va_start found");
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
325 fdecl->llvmInternal = LLVMva_start;
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
326 }
527
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 526
diff changeset
327 else if (tempdecl->llvmInternal == LLVMintrinsic)
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 526
diff changeset
328 {
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 526
diff changeset
329 Logger::println("overloaded intrinsic found");
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 526
diff changeset
330 fdecl->llvmInternal = LLVMintrinsic;
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 526
diff changeset
331 DtoOverloadedIntrinsicName(tinst, tempdecl, fdecl->intrinsicName);
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
332 fdecl->linkage = LINKintrinsic;
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
333 ((TypeFunction*)fdecl->type)->linkage = LINKintrinsic;
527
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 526
diff changeset
334 }
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
335 }
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
336
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
337 DtoFunctionType(fdecl);
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
338
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
339 if (fdecl->ir.resolved) return;
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
340 fdecl->ir.resolved = true;
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
341
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
342 Logger::println("DtoResolveFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars());
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
343 LOG_SCOPE;
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
344
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
345 // queue declaration
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 109
diff changeset
346 if (!fdecl->isAbstract())
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
347 {
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
348 Logger::println("Ignoring declaration of abstract function %s", fdecl->toPrettyChars());
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
349 DtoDeclareFunction(fdecl);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
350 }
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
351 }
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
352
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
353 //////////////////////////////////////////////////////////////////////////////////////////
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
354
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
355 static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl)
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
356 {
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
357 int funcNumArgs = func->getArgumentList().size();
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
358
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
359 LLSmallVector<llvm::AttributeWithIndex, 9> attrs;
632
df196c8dea26 Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 622
diff changeset
360 llvm::AttributeWithIndex PAWI;
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
361
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
362 int idx = 0;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
363
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
364 // handle implicit args
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
365 #define ADD_PA(X) \
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
366 if (f->fty.X) { \
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
367 if (f->fty.X->attrs) { \
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
368 PAWI.Index = idx; \
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
369 PAWI.Attrs = f->fty.X->attrs; \
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
370 attrs.push_back(PAWI); \
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
371 } \
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
372 idx++; \
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
373 }
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
374
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
375 ADD_PA(ret)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
376 ADD_PA(arg_sret)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
377 ADD_PA(arg_this)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
378 ADD_PA(arg_nest)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
379 ADD_PA(arg_arguments)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
380 ADD_PA(arg_argptr)
454
283d113d4753 Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
381
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
382 #undef ADD_PA
720
e177ae483f8e Added inreg attribute where appropriate on x86 to follow ABI docs.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
383
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
384 // set attrs on the rest of the arguments
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
385 size_t n = Argument::dim(f->parameters);
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
386 LLSmallVector<unsigned,8> attrptr(n, 0);
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
387
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
388 for (size_t k = 0; k < n; ++k)
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
389 {
454
283d113d4753 Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
390 Argument* fnarg = Argument::getNth(f->parameters, k);
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
391 assert(fnarg);
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
392
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
393 attrptr[k] = f->fty.args[k]->attrs;
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
394 }
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
395
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
396 // reverse params?
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
397 if (f->fty.reverseParams)
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
398 {
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
399 std::reverse(attrptr.begin(), attrptr.end());
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
400 }
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
401
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
402 // build rest of attrs list
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
403 for (int i = 0; i < n; i++)
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
404 {
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
405 if (attrptr[i])
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
406 {
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
407 PAWI.Index = idx+i;
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
408 PAWI.Attrs = attrptr[i];
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
409 attrs.push_back(PAWI);
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
410 }
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
411 }
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
412
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
413 llvm::AttrListPtr attrlist = llvm::AttrListPtr::get(attrs.begin(), attrs.end());
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
414 func->setAttributes(attrlist);
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
415 }
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
416
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
417 //////////////////////////////////////////////////////////////////////////////////////////
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
418
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
419 void DtoDeclareFunction(FuncDeclaration* fdecl)
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
420 {
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
421 if (fdecl->ir.declared) return;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
422 fdecl->ir.declared = true;
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
423
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
424 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars());
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
425 LOG_SCOPE;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
426
622
26fce59fe80a Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 585
diff changeset
427 //printf("declare function: %s\n", fdecl->toPrettyChars());
26fce59fe80a Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 585
diff changeset
428
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
429 // intrinsic sanity check
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
430 if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) {
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
431 error(fdecl->loc, "intrinsics cannot have function bodies");
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
432 fatal();
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
433 }
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
434
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
435 // get TypeFunction*
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
436 Type* t = fdecl->type->toBasetype();
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
437 TypeFunction* f = (TypeFunction*)t;
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
438
940
39519a1ff603 Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 939
diff changeset
439 bool declareOnly = !mustDefineSymbol(fdecl);
39519a1ff603 Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 939
diff changeset
440
39519a1ff603 Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 939
diff changeset
441 if (fdecl->llvmInternal == LLVMva_start)
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
442 declareOnly = true;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
443
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
444 if (!fdecl->ir.irFunc) {
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
445 fdecl->ir.irFunc = new IrFunction(fdecl);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
446 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
447
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
448 // mangled name
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 435
diff changeset
449 const char* mangled_name;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
450 if (fdecl->llvmInternal == LLVMintrinsic)
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 435
diff changeset
451 mangled_name = fdecl->intrinsicName.c_str();
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
452 else
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
453 mangled_name = fdecl->mangle();
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
454
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
455 llvm::Function* vafunc = 0;
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
456 if (fdecl->isVaIntrinsic())
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
457 vafunc = DtoDeclareVaFunction(fdecl);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
458
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
459 // construct function
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
460 const llvm::FunctionType* functype = DtoFunctionType(fdecl);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
461 llvm::Function* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
462 if (!func)
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 173
diff changeset
463 func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
464
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
465 // add func to IRFunc
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
466 fdecl->ir.irFunc->func = func;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
467
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
468 // calling convention
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
469 if (!vafunc && fdecl->llvmInternal != LLVMintrinsic)
933
d3a6f1a96731 Replace assertion with errormessage for unsupported calling conventions. like Pascal. See dstress/run/e/extern_10_A.d
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 930
diff changeset
470 func->setCallingConv(DtoCallingConv(fdecl->loc, f->linkage));
149
4c577c2b7229 [svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents: 144
diff changeset
471 else // fall back to C, it should be the right thing to do
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
472 func->setCallingConv(llvm::CallingConv::C);
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
473
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
474 fdecl->ir.irFunc->func = func;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
475 assert(llvm::isa<llvm::FunctionType>(f->ir.type->get()));
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
476
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 215
diff changeset
477 // parameter attributes
454
283d113d4753 Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
478 if (!fdecl->isIntrinsic()) {
240
0db62b770a49 [svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents: 234
diff changeset
479 set_param_attrs(f, func, fdecl);
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 215
diff changeset
480 }
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 215
diff changeset
481
116
fd7ad91fd713 [svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents: 113
diff changeset
482 // main
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
483 if (fdecl->isMain()) {
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
484 gIR->mainFunc = func;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
485 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
486
116
fd7ad91fd713 [svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents: 113
diff changeset
487 // static ctor
934
b56f3571c450 Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 933
diff changeset
488 if (fdecl->isStaticCtorDeclaration()) {
958
89729c76b8ff Static ctors/dtors added via template mixins should not be added to modules
Christian Kamm <kamm incasoftware de>
parents: 947
diff changeset
489 if (mustDefineSymbol(fdecl)) {
934
b56f3571c450 Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 933
diff changeset
490 gIR->ctors.push_back(fdecl);
b56f3571c450 Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 933
diff changeset
491 }
116
fd7ad91fd713 [svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents: 113
diff changeset
492 }
fd7ad91fd713 [svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents: 113
diff changeset
493 // static dtor
934
b56f3571c450 Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 933
diff changeset
494 else if (fdecl->isStaticDtorDeclaration()) {
958
89729c76b8ff Static ctors/dtors added via template mixins should not be added to modules
Christian Kamm <kamm incasoftware de>
parents: 947
diff changeset
495 if (mustDefineSymbol(fdecl)) {
934
b56f3571c450 Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 933
diff changeset
496 gIR->dtors.push_back(fdecl);
b56f3571c450 Fixed problem with static ctors, in templated imported classes, not begin run. Fixes #203
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 933
diff changeset
497 }
116
fd7ad91fd713 [svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents: 113
diff changeset
498 }
fd7ad91fd713 [svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents: 113
diff changeset
499
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
500 // we never reference parameters of function prototypes
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
501 std::string str;
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
502 if (!declareOnly)
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
503 {
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
504 // name parameters
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
505 llvm::Function::arg_iterator iarg = func->arg_begin();
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
506
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
507 if (f->fty.arg_sret) {
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
508 iarg->setName(".sret_arg");
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
509 fdecl->ir.irFunc->retArg = iarg;
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
510 ++iarg;
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
511 }
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
512
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
513 if (f->fty.arg_this) {
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
514 iarg->setName(".this_arg");
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
515 fdecl->ir.irFunc->thisArg = iarg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
516 assert(fdecl->ir.irFunc->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
517 ++iarg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
518 }
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
519 else if (f->fty.arg_nest) {
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
520 iarg->setName(".nest_arg");
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
521 fdecl->ir.irFunc->nestArg = iarg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
522 assert(fdecl->ir.irFunc->nestArg);
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
523 ++iarg;
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
524 }
119
79c9ac745fbc [svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents: 117
diff changeset
525
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
526 if (f->fty.arg_argptr) {
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
527 iarg->setName("._arguments");
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
528 fdecl->ir.irFunc->_arguments = iarg;
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
529 ++iarg;
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
530 iarg->setName("._argptr");
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
531 fdecl->ir.irFunc->_argptr = iarg;
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
532 ++iarg;
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
533 }
119
79c9ac745fbc [svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents: 117
diff changeset
534
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
535 int k = 0;
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
536
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
537 for (; iarg != func->arg_end(); ++iarg)
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
538 {
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
539 if (fdecl->parameters && fdecl->parameters->dim > k)
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
540 {
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
541 Dsymbol* argsym;
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
542 if (f->fty.reverseParams)
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
543 argsym = (Dsymbol*)fdecl->parameters->data[fdecl->parameters->dim-k-1];
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
544 else
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
545 argsym = (Dsymbol*)fdecl->parameters->data[k];
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
546
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
547 VarDeclaration* argvd = argsym->isVarDeclaration();
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
548 assert(argvd);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
549 assert(!argvd->ir.irLocal);
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
550 argvd->ir.irLocal = new IrLocal(argvd);
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
551 argvd->ir.irLocal->value = iarg;
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
552
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
553 str = argvd->ident->toChars();
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
554 str.append("_arg");
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
555 iarg->setName(str);
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
556
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
557 k++;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
558 }
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
559 else
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
560 {
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
561 iarg->setName("unnamed");
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
562 }
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
563 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
564 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
565
830
504a21e81a46 Only run unittests contained directly in the module.
Christian Kamm <kamm incasoftware de>
parents: 797
diff changeset
566 if (fdecl->isUnitTestDeclaration() && !declareOnly)
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
567 gIR->unitTests.push_back(fdecl);
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 119
diff changeset
568
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
569 if (!declareOnly)
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1117
diff changeset
570 Type::sir->addFunctionBody(fdecl->ir.irFunc);
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
571 else
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
572 assert(func->getLinkage() != llvm::GlobalValue::InternalLinkage);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
573 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
574
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
575 //////////////////////////////////////////////////////////////////////////////////////////
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
576
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
577 // FIXME: this isn't too pretty!
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
578
920
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
579 void DtoDefineFunction(FuncDeclaration* fd)
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
580 {
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
581 if (fd->ir.defined) return;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
582 fd->ir.defined = true;
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
583
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
584 assert(fd->ir.declared);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 102
diff changeset
585
1047
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
586 if (Logger::enabled())
6bb04dbee21f Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents: 1045
diff changeset
587 Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars());
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
588 LOG_SCOPE;
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
589
920
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
590 // if this function is naked, we take over right away! no standard processing!
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
591 if (fd->naked)
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
592 {
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
593 DtoDefineNakedFunction(fd);
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
594 return;
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
595 }
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
596
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
597 // debug info
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
598 if (global.params.symdebug) {
946
1714836f2c0b Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents: 945
diff changeset
599 fd->ir.irFunc->diSubprogram = DtoDwarfSubProgram(fd);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
600 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
601
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
602 Type* t = fd->type->toBasetype();
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
603 TypeFunction* f = (TypeFunction*)t;
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
604 assert(f->ir.type);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
605
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
606 llvm::Function* func = fd->ir.irFunc->func;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
607 const llvm::FunctionType* functype = func->getFunctionType();
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
608
940
39519a1ff603 Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 939
diff changeset
609 // sanity check
39519a1ff603 Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 939
diff changeset
610 assert(mustDefineSymbol(fd));
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
611
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
612 // set module owner
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
613 fd->ir.DModule = gIR->dmodule;
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 173
diff changeset
614
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
615 // is there a body?
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
616 if (fd->fbody == NULL)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
617 return;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
618
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
619 Logger::println("Doing function body for: %s", fd->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
620 assert(fd->ir.irFunc);
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
621 IrFunction* irfunction = fd->ir.irFunc;
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
622 gIR->functions.push_back(irfunction);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 102
diff changeset
623
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
624 if (fd->isMain())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
625 gIR->emitMain = true;
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
626
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
627 std::string entryname("entry");
162
1856c62af24b [svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents: 157
diff changeset
628
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
629 llvm::BasicBlock* beginbb = llvm::BasicBlock::Create(entryname,func);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
630 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endentry",func);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
631
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
632 //assert(gIR->scopes.empty());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
633 gIR->scopes.push_back(IRScope(beginbb, endbb));
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 102
diff changeset
634
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
635 // create alloca point
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
636 llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::Int32Ty, "alloca point", beginbb);
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
637 irfunction->allocapoint = allocaPoint;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
638
452
30ef3c7bddca Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 449
diff changeset
639 // debug info - after all allocas, but before any llvm.dbg.declare etc
30ef3c7bddca Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 449
diff changeset
640 if (global.params.symdebug) DtoDwarfFuncStart(fd);
30ef3c7bddca Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 449
diff changeset
641
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
642 // need result variable?
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
643 if (fd->vresult) {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
644 Logger::println("vresult value");
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
645 fd->vresult->ir.irLocal = new IrLocal(fd->vresult);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
646 fd->vresult->ir.irLocal->value = DtoAlloca(DtoType(fd->vresult->type), "function_vresult");
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
647 }
526
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
648
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
649 // this hack makes sure the frame pointer elimination optimization is disabled.
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
650 // this this eliminates a bunch of inline asm related issues.
920
545f54041d91 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 838
diff changeset
651 if (fd->inlineAsm)
526
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
652 {
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
653 // emit a call to llvm_eh_unwind_init
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
654 LLFunction* hack = GET_INTRINSIC_DECL(eh_unwind_init);
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
655 gIR->ir->CreateCall(hack, "");
642f6fa854e5 First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 523
diff changeset
656 }
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
657
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
658 // give the 'this' argument storage and debug info
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
659 if (f->fty.arg_this)
254
8187884566fa [svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents: 250
diff changeset
660 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
661 LLValue* thisvar = irfunction->thisArg;
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
662 assert(thisvar);
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
663
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
664 LLValue* thismem = DtoAlloca(thisvar->getType(), "this");
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
665 DtoStore(thisvar, thismem);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
666 irfunction->thisArg = thismem;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
667
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
668 assert(!fd->vthis->ir.irLocal);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
669 fd->vthis->ir.irLocal = new IrLocal(fd->vthis);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
670 fd->vthis->ir.irLocal->value = thismem;
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
671
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
672 if (global.params.symdebug)
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
673 DtoDwarfLocalVariable(thismem, fd->vthis);
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
674
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
675 #if DMDV2
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
676 if (fd->vthis->nestedrefs.dim)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
677 #else
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
678 if (fd->vthis->nestedref)
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
679 #endif
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
680 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
681 fd->nestedVars.insert(fd->vthis);
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
682 }
254
8187884566fa [svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents: 250
diff changeset
683 }
8187884566fa [svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents: 250
diff changeset
684
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
685 // give arguments storage
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 457
diff changeset
686 // and debug info
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
687 if (fd->parameters)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
688 {
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
689 size_t n = f->fty.args.size();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1018
diff changeset
690 assert(n == fd->parameters->dim);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
691 for (int i=0; i < n; ++i)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
692 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
693 Dsymbol* argsym = (Dsymbol*)fd->parameters->data[i];
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
694 VarDeclaration* vd = argsym->isVarDeclaration();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
695 assert(vd);
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
696
930
7985bb036db4 Follow the D ABI and pass the last arg in a register if it is a struct that fits.
Christian Kamm <kamm incasoftware de>
parents: 920
diff changeset
697 IrLocal* irloc = vd->ir.irLocal;
7985bb036db4 Follow the D ABI and pass the last arg in a register if it is a struct that fits.
Christian Kamm <kamm incasoftware de>
parents: 920
diff changeset
698 assert(irloc);
7985bb036db4 Follow the D ABI and pass the last arg in a register if it is a struct that fits.
Christian Kamm <kamm incasoftware de>
parents: 920
diff changeset
699
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
700 #if DMDV2
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
701 if (vd->nestedrefs.dim)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
702 #else
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
703 if (vd->nestedref)
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
704 #endif
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
705 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
706 fd->nestedVars.insert(vd);
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
707 }
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
708
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
709 bool refout = vd->storage_class & (STCref | STCout);
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
710 bool lazy = vd->storage_class & STClazy;
457
d82ebdba4191 Fixed debug info and lazy arguments.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 455
diff changeset
711
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
712 if (!refout && (!f->fty.args[i]->byref || lazy))
254
8187884566fa [svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents: 250
diff changeset
713 {
1042
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
714 // alloca a stack slot for this first class value arg
1045
a91d6fc600cd Fixed lazy arguments again.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1042
diff changeset
715 const LLType* argt;
a91d6fc600cd Fixed lazy arguments again.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1042
diff changeset
716 if (lazy)
a91d6fc600cd Fixed lazy arguments again.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1042
diff changeset
717 argt = irloc->value->getType();
a91d6fc600cd Fixed lazy arguments again.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1042
diff changeset
718 else
a91d6fc600cd Fixed lazy arguments again.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1042
diff changeset
719 argt = DtoType(vd->type);
a91d6fc600cd Fixed lazy arguments again.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1042
diff changeset
720 LLValue* mem = DtoAlloca(argt, vd->ident->toChars());
1042
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
721
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
722 // let the abi transform the argument back first
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
723 DImValue arg_dval(vd->type, irloc->value);
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1049
diff changeset
724 f->fty.getParam(vd->type, i, &arg_dval, mem);
1042
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
725
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
726 // set the arg var value to the alloca
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
727 irloc->value = mem;
254
8187884566fa [svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents: 250
diff changeset
728 }
1042
45af482e3832 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1024
diff changeset
729
752
2d7bcfa68128 Enable function parameter debug info for a wider range of args.
Christian Kamm <kamm incasoftware de>
parents: 739
diff changeset
730 if (global.params.symdebug && !(isaArgument(irloc->value) && !isaArgument(irloc->value)->hasByValAttr()) && !refout)
2d7bcfa68128 Enable function parameter debug info for a wider range of args.
Christian Kamm <kamm incasoftware de>
parents: 739
diff changeset
731 DtoDwarfLocalVariable(irloc->value, vd);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
732 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
733 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
734
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
735 // need result variable? (nested)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
736 #if DMDV2
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
737 if (fd->vresult && fd->vresult->nestedrefs.dim) {
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
738 #else
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
739 if (fd->vresult && fd->vresult->nestedref) {
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
740 #endif
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
741 Logger::println("nested vresult value: %s", fd->vresult->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
742 fd->nestedVars.insert(fd->vresult);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
743 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
744
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
745 // construct nested variables array
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
746 if (!fd->nestedVars.empty())
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
747 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
748 Logger::println("has nested frame");
838
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
749 // start with adding all enclosing parent frames until a static parent is reached
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
750 int nparelems = 0;
838
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
751 if (!fd->isStatic())
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
752 {
838
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
753 Dsymbol* par = fd->toParent2();
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
754 while (par)
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
755 {
838
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
756 if (FuncDeclaration* parfd = par->isFuncDeclaration())
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
757 {
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
758 nparelems += parfd->nestedVars.size();
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
759 // stop at first static
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
760 if (parfd->isStatic())
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
761 break;
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
762 }
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
763 else if (ClassDeclaration* parcd = par->isClassDeclaration())
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
764 {
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
765 // nothing needed
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
766 }
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
767 else
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
768 {
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
769 break;
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
770 }
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
771
94ba810ea2b0 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 837
diff changeset
772 par = par->toParent2();
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
773 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
774 }
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
775 int nelems = fd->nestedVars.size() + nparelems;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
776
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
777 // make array type for nested vars
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
778 const LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
779
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
780 // alloca it
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
781 LLValue* nestedVars = DtoAlloca(nestedVarsTy, ".nested_vars");
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
782
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
783 // copy parent frame into beginning
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
784 if (nparelems)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
785 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
786 LLValue* src = irfunction->nestArg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
787 if (!src)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
788 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
789 assert(irfunction->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
790 assert(fd->isMember2());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
791 LLValue* thisval = DtoLoad(irfunction->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
792 ClassDeclaration* cd = fd->isMember2()->isClassDeclaration();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
793 assert(cd);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
794 assert(cd->vthis);
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
795 src = DtoLoad(DtoGEPi(thisval, 0,cd->vthis->ir.irField->index, ".vthis"));
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
796 }
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
797 DtoMemCpy(nestedVars, src, DtoConstSize_t(nparelems*PTRSIZE));
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
798 }
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
799
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
800 // store in IrFunction
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
801 irfunction->nestedVar = nestedVars;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
802
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
803 // go through all nested vars and assign indices
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
804 int idx = nparelems;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
805 for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
806 {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
807 VarDeclaration* vd = *i;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
808 if (!vd->ir.irLocal)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
809 vd->ir.irLocal = new IrLocal(vd);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
810
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
811 if (vd->isParameter())
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
812 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
813 Logger::println("nested param: %s", vd->toChars());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
814 LLValue* gep = DtoGEPi(nestedVars, 0, idx);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
815 LLValue* val = DtoBitCast(vd->ir.irLocal->value, getVoidPtrType());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
816 DtoStore(val, gep);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
817 }
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
818 else
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
819 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
820 Logger::println("nested var: %s", vd->toChars());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
821 }
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
822
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
823 vd->ir.irLocal->nestedIndex = idx++;
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
824 }
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
825
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
826 // fixup nested result variable
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
827 #if DMDV2
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
828 if (fd->vresult && fd->vresult->nestedrefs.dim) {
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
829 #else
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
830 if (fd->vresult && fd->vresult->nestedref) {
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 752
diff changeset
831 #endif
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
832 Logger::println("nested vresult value: %s", fd->vresult->toChars());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
833 LLValue* gep = DtoGEPi(nestedVars, 0, fd->vresult->ir.irLocal->nestedIndex);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
834 LLValue* val = DtoBitCast(fd->vresult->ir.irLocal->value, getVoidPtrType());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
835 DtoStore(val, gep);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
836 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
837 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
838
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
839 // copy _argptr and _arguments to a memory location
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
840 if (f->linkage == LINKd && f->varargs == 1)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
841 {
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
842 // _argptr
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
843 LLValue* argptrmem = DtoAlloca(fd->ir.irFunc->_argptr->getType(), "_argptr_mem");
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
844 new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
845 fd->ir.irFunc->_argptr = argptrmem;
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
846
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
847 // _arguments
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
848 LLValue* argumentsmem = DtoAlloca(fd->ir.irFunc->_arguments->getType(), "_arguments_mem");
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
849 new llvm::StoreInst(fd->ir.irFunc->_arguments, argumentsmem, gIR->scopebb());
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 632
diff changeset
850 fd->ir.irFunc->_arguments = argumentsmem;
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
851 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
852
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
853 // output function body
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
854 fd->fbody->toIR(gIR);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
855
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
856 // TODO: clean up this mess
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
857
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
858 // std::cout << *func << std::endl;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
859
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
860 // llvm requires all basic blocks to end with a TerminatorInst but DMD does not put a return statement
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
861 // in automatically, so we do it here.
428
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
862 if (!gIR->scopereturned()) {
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
863 // pass the previous block into this block
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
864 if (global.params.symdebug) DtoDwarfFuncEnd(fd);
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
865 if (func->getReturnType() == LLType::VoidTy) {
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
866 llvm::ReturnInst::Create(gIR->scopebb());
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
867 }
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
868 else {
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
869 if (!fd->isMain())
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
870 {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
871 AsmBlockStatement* asmb = fd->fbody->endsWithAsm();
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
872 if (asmb) {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
873 assert(asmb->abiret);
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
874 llvm::ReturnInst::Create(asmb->abiret, gIR->scopebb());
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
875 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
876 else {
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
877 llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), gIR->scopebb());
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
878 }
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
879 }
428
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
880 else
8b7cee241e91 Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
881 llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), gIR->scopebb());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
882 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
883 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
884
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
885 // std::cout << *func << std::endl;
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
886
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
887 // erase alloca point
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
888 allocaPoint->eraseFromParent();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
889 allocaPoint = 0;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
890 gIR->func()->allocapoint = 0;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
891
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
892 gIR->scopes.pop_back();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
893
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
894 // get rid of the endentry block, it's never used
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
895 assert(!func->getBasicBlockList().empty());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
896 func->getBasicBlockList().pop_back();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
897
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
898 gIR->functions.pop_back();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 241
diff changeset
899
945
03d7c4aac654 SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 940
diff changeset
900 // std::cout << *func << std::endl;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
901 }
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
902
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
903 //////////////////////////////////////////////////////////////////////////////////////////
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents:
diff changeset
904
117
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
905 const llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl)
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
906 {
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
907 Dsymbol* parent = fdecl->toParent();
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
908 ClassDeclaration* cd = parent->isClassDeclaration();
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
909 assert(cd);
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
910
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
911 FuncDeclaration* f = fdecl;
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
912
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
913 while (cd)
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
914 {
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
915 ClassDeclaration* base = cd->baseClass;
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
916 if (!base)
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
917 break;
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
918 FuncDeclaration* f2 = base->findFunc(fdecl->ident, (TypeFunction*)fdecl->type);
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
919 if (f2) {
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
920 f = f2;
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
921 cd = base;
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
922 }
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
923 else
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
924 break;
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
925 }
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
926
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
927 DtoResolveDsymbol(f);
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
928 return llvm::cast<llvm::FunctionType>(DtoType(f->type));
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
929 }
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
930
56a21f3e5d3e [svn r121] Finished ModuleInfo implementation.
lindquist
parents: 116
diff changeset
931 //////////////////////////////////////////////////////////////////////////////////////////
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
932
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
933 DValue* DtoArgument(Argument* fnarg, Expression* argexp)
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
934 {
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
935 Logger::println("DtoArgument");
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
936 LOG_SCOPE;
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
937
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
938 DValue* arg = argexp->toElem(gIR);
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
939
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
940 // ref/out arg
723
55f6c2e454d7 Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 720
diff changeset
941 if (fnarg && (fnarg->storageClass & (STCref | STCout)))
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
942 {
1151
3cf0066e6faf - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1149
diff changeset
943 if (arg->isVar())
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
944 arg = new DImValue(argexp->type, arg->getLVal());
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
945 else
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
946 arg = new DImValue(argexp->type, arg->getRVal());
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
947 }
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
948 // lazy arg
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
949 else if (fnarg && (fnarg->storageClass & STClazy))
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
950 {
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
951 assert(argexp->type->toBasetype()->ty == Tdelegate);
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
952 assert(!arg->isLVal());
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
953 return arg;
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
954 }
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 215
diff changeset
955 // byval arg, but expr has no storage yet
585
fbb1a366cfbc Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 546
diff changeset
956 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isNull()))
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
957 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 479
diff changeset
958 LLValue* alloc = DtoAlloca(DtoType(argexp->type), ".tmp_arg");
585
fbb1a366cfbc Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 546
diff changeset
959 DVarValue* vv = new DVarValue(argexp->type, alloc);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 379
diff changeset
960 DtoAssign(argexp->loc, vv, arg);
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
961 arg = vv;
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
962 }
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
963
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
964 return arg;
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
965 }
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
966
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
967 //////////////////////////////////////////////////////////////////////////////////////////
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
968
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 205
diff changeset
969 void DtoVariadicArgument(Expression* argexp, LLValue* dst)
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
970 {
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
971 Logger::println("DtoVariadicArgument");
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
972 LOG_SCOPE;
585
fbb1a366cfbc Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 546
diff changeset
973 DVarValue vv(argexp->type, dst);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 379
diff changeset
974 DtoAssign(argexp->loc, &vv, argexp->toElem(gIR));
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
975 }
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
976
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 129
diff changeset
977 //////////////////////////////////////////////////////////////////////////////////////////
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
978
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
979 bool FuncDeclaration::isIntrinsic()
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
980 {
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
981 return (llvmInternal == LLVMintrinsic || isVaIntrinsic());
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
982 }
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
983
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
984 bool FuncDeclaration::isVaIntrinsic()
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
985 {
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
986 return (llvmInternal == LLVMva_start ||
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
987 llvmInternal == LLVMva_copy ||
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
988 llvmInternal == LLVMva_end);
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 443
diff changeset
989 }