annotate ir/irfunction.cpp @ 1050:32ead42679d1

Fix a bug in the X86 ABI. The size of a struct is different from the size of a pointer to that struct...
author Frits van Bommel <fvbommel wxs.nl>
date Fri, 06 Mar 2009 21:15:13 +0100
parents 45af482e3832
children dc608dc33081
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 207
diff changeset
1
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 207
diff changeset
2 #include "gen/llvm.h"
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
3 #include "gen/tollvm.h"
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
4 #include "gen/abi.h"
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
5 #include "gen/dvalue.h"
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
6 #include "gen/logger.h"
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
7 #include "ir/irfunction.h"
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
8
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
9 #include <sstream>
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
10
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
11 //////////////////////////////////////////////////////////////////////////////
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
12 //////////////////////////////////////////////////////////////////////////////
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
13 //////////////////////////////////////////////////////////////////////////////
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
14
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
15 IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, unsigned a)
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
16 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
17 type = t;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
18 ltype = bref ? DtoType(t->pointerTo()) : DtoType(t);
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
19 attrs = a;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
20 byref = bref;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
21 rewrite = NULL;
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
22 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
23
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
24 //////////////////////////////////////////////////////////////////////////////
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
25 //////////////////////////////////////////////////////////////////////////////
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
26 //////////////////////////////////////////////////////////////////////////////
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
27
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
28 llvm::Value* IrFuncTy::putRet(Type* dty, DValue* val)
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
29 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
30 assert(!arg_sret);
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
31 if (ret->rewrite) {
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
32 Logger::println("Rewrite: putRet");
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
33 LOG_SCOPE
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
34 return ret->rewrite->put(dty, val);
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
35 }
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
36 return val->getRVal();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
37 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
38
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
39 llvm::Value* IrFuncTy::getRet(Type* dty, DValue* val)
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
40 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
41 assert(!arg_sret);
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
42 if (ret->rewrite) {
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
43 Logger::println("Rewrite: getRet");
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
44 LOG_SCOPE
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
45 return ret->rewrite->get(dty, val);
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
46 }
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
47 return val->getRVal();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
48 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
49
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
50 llvm::Value* IrFuncTy::putParam(Type* dty, int idx, DValue* val)
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
51 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
52 assert(idx >= 0 && idx < args.size() && "invalid putParam");
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
53 if (args[idx]->rewrite) {
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
54 Logger::println("Rewrite: putParam");
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
55 LOG_SCOPE
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
56 return args[idx]->rewrite->put(dty, val);
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
57 }
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
58 return val->getRVal();
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
59 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
60
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
61 llvm::Value* IrFuncTy::getParam(Type* dty, int idx, DValue* val)
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
62 {
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
63 assert(idx >= 0 && idx < args.size() && "invalid getParam");
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
64 if (args[idx]->rewrite) {
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
65 Logger::println("Rewrite: getParam (get)");
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
66 LOG_SCOPE
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
67 return args[idx]->rewrite->get(dty, val);
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
68 }
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
69 return val->getRVal();
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
70 }
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
71
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
72 void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval)
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
73 {
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
74 assert(idx >= 0 && idx < args.size() && "invalid getParam");
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
75
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
76 if (args[idx]->rewrite)
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
77 {
1050
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
78 Logger::println("Rewrite: getParam (getL)");
32ead42679d1 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents: 1042
diff changeset
79 LOG_SCOPE
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
80 args[idx]->rewrite->getL(dty, val, lval);
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
81 return;
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
82 }
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
83
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
84 DtoStore(val->getRVal(), lval);
1024
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
85 }
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
86
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
87 //////////////////////////////////////////////////////////////////////////////
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
88 //////////////////////////////////////////////////////////////////////////////
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
89 //////////////////////////////////////////////////////////////////////////////
9167d492cbc2 Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 946
diff changeset
90
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
91 IrFunction::IrFunction(FuncDeclaration* fd)
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
92 {
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
93 decl = fd;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
94
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: 355
diff changeset
95 Type* t = fd->type->toBasetype();
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
96 assert(t->ty == Tfunction);
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
97 type = (TypeFunction*)t;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
98 func = NULL;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
99 allocapoint = NULL;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
100
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
101 queued = false;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
102 defined = false;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
103
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
104 retArg = NULL;
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: 355
diff changeset
105 thisArg = NULL;
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: 355
diff changeset
106 nestArg = NULL;
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: 355
diff changeset
107
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
108 nestedVar = NULL;
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: 355
diff changeset
109
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
110 _arguments = NULL;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
111 _argptr = NULL;
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: 355
diff changeset
112
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
113 nextUnique.push(0);
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
114 }
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
115
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
116 std::string IrFunction::getScopedLabelName(const char* ident)
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
117 {
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
118 if(labelScopes.empty())
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
119 return std::string(ident);
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
120
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
121 std::string result = "__";
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
122 for(unsigned int i = 0; i < labelScopes.size(); ++i)
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
123 result += labelScopes[i] + "_";
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
124 return result + ident;
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
125 }
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
126
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
127 void IrFunction::pushUniqueLabelScope(const char* name)
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
128 {
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
129 std::ostringstream uniquename;
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
130 uniquename << name << nextUnique.top()++;
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
131 nextUnique.push(0);
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
132 labelScopes.push_back(uniquename.str());
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
133 }
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
134
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
135 void IrFunction::popLabelScope()
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
136 {
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
137 labelScopes.pop_back();
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
138 nextUnique.pop();
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 309
diff changeset
139 }
584
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
140
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
141 void IrFunction::setNeverInline()
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
142 {
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: 584
diff changeset
143 assert(!func->hasFnAttr(llvm::Attribute::AlwaysInline) && "function can't be never- and always-inline at the same time");
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: 584
diff changeset
144 func->addFnAttr(llvm::Attribute::NoInline);
584
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
145 }
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
146
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
147 void IrFunction::setAlwaysInline()
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
148 {
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: 584
diff changeset
149 assert(!func->hasFnAttr(llvm::Attribute::NoInline) && "function can't be never- and always-inline at the same time");
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: 584
diff changeset
150 func->addFnAttr(llvm::Attribute::AlwaysInline);
584
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
151 }