hobbes
a language, embedded compiler, and runtime for efficient dynamic expression evaluation, data storage and analysis
llvm.H
Go to the documentation of this file.
1 
2 #ifndef HOBBES_UTIL_LLVM_HPP_INCLUDED
3 #define HOBBES_UTIL_LLVM_HPP_INCLUDED
4 
5 #include <hobbes/util/array.H>
6 
7 #include <llvm/Config/llvm-config.h>
8 
9 #if LLVM_VERSION_MAJOR != 3
10 #error "I don't know how to use this version of LLVM"
11 #endif
12 
13 #include <llvm/IR/DerivedTypes.h>
14 #include <llvm/IR/IRBuilder.h>
15 #include <llvm/IR/LLVMContext.h>
16 #include <llvm/IR/Module.h>
17 #include <llvm/IR/DataLayout.h>
18 #include <llvm/IR/InstIterator.h>
19 #include <llvm/Analysis/Passes.h>
20 #include <llvm/Transforms/Scalar.h>
21 #include <llvm/Transforms/Vectorize.h>
22 #include <llvm/Transforms/IPO.h>
23 #include <llvm/Transforms/Utils/Cloning.h>
24 #include <llvm/Support/TargetSelect.h>
25 #include <llvm/Support/TargetRegistry.h>
26 #include <llvm/Support/Signals.h>
27 #include <llvm/Bitcode/ReaderWriter.h>
28 #include <llvm/Support/raw_os_ostream.h>
29 #include <llvm/ExecutionEngine/ExecutionEngine.h>
30 #include <llvm/ExecutionEngine/JITEventListener.h>
31 #include <llvm/ExecutionEngine/SectionMemoryManager.h>
32 
33 #if LLVM_VERSION_MINOR == 3
34 #include <llvm/Analysis/Verifier.h>
35 #include <llvm/PassManager.h>
36 #elif LLVM_VERSION_MINOR >= 5
37 #include <llvm/IR/Verifier.h>
38 #include <llvm/ExecutionEngine/SectionMemoryManager.h>
39 #include <llvm/IR/LegacyPassManager.h>
40 #include <llvm/Object/ELFObjectFile.h>
41 #endif
42 
43 namespace hobbes {
44 
45 // keep one context per thread to avoid global locking
46 // NOTE: temporarily reverting to one global context
47 // this is because we have some cases where we partially compile in one thread and then resume compiling in another thread
48 // we currently keep a global lock on compilers anyway
49 inline llvm::LLVMContext& context() {
50  return llvm::getGlobalContext();
51 }
52 
53 typedef std::vector<llvm::Type*> Types;
54 typedef std::vector<llvm::Constant*> Constants;
55 typedef std::vector<llvm::Value*> Values;
56 
57 // type utilities
58 inline llvm::Type* voidType() {
59  return llvm::Type::getVoidTy(context());
60 }
61 
62 inline llvm::Type* boolType() {
63  return llvm::Type::getInt1Ty(context());
64 }
65 
66 inline llvm::Type* charType() {
67  return llvm::Type::getInt8Ty(context());
68 }
69 
70 inline llvm::Type* byteType() {
71  return charType();
72 }
73 
74 inline llvm::Type* shortType() {
75  return llvm::Type::getInt16Ty(context());
76 }
77 
78 inline llvm::Type* intType() {
79  return llvm::Type::getInt32Ty(context());
80 }
81 
82 inline llvm::Type* longType() {
83  return llvm::Type::getInt64Ty(context());
84 }
85 
86 inline llvm::Type* floatType() {
87  return llvm::Type::getFloatTy(context());
88 }
89 
90 inline llvm::Type* doubleType() {
91  return llvm::Type::getDoubleTy(context());
92 }
93 
94 inline llvm::PointerType* ptrType(llvm::Type* ty) {
95  return llvm::PointerType::getUnqual(ty);
96 }
97 
98 inline llvm::ArrayType* arrayType(llvm::Type* ty, size_t sz) {
99  // we can be a little dishonest in describing the type of arrays of unit, since LLVM barfs on arrays of unit
100  // and we should never need to look at the "data" in an array of unit values _anyway_!
101  return llvm::ArrayType::get(ty->isVoidTy() ? boolType() : ty, (uint64_t)sz);
102 }
103 
104 inline llvm::StructType* packedRecordType(const Types& tys) {
105  return llvm::StructType::get(context(), tys, true);
106 }
107 
108 inline llvm::StructType* recordType(const Types& tys) {
109  return llvm::StructType::get(context(), tys);
110 }
111 
112 inline llvm::StructType* recordType(llvm::Type* t0) {
113  return recordType(list(t0));
114 }
115 
116 inline llvm::StructType* recordType(llvm::Type* t0, llvm::Type* t1) {
117  return recordType(list(t0, t1));
118 }
119 
120 inline llvm::StructType* recordType(llvm::Type* t0, llvm::Type* t1, llvm::Type* t2) {
121  return recordType(list(t0, t1, t2));
122 }
123 
124 inline llvm::StructType* recordType(llvm::Type* t0, llvm::Type* t1, llvm::Type* t2, llvm::Type* t3) {
125  return recordType(list(t0, t1, t2, t3));
126 }
127 
128 inline llvm::StructType* recordType(llvm::Type* t0, llvm::Type* t1, llvm::Type* t2, llvm::Type* t3, llvm::Type* t4) {
129  return recordType(list(t0, t1, t2, t3, t4));
130 }
131 
132 inline llvm::StructType* recordType(llvm::Type* t0, llvm::Type* t1, llvm::Type* t2, llvm::Type* t3, llvm::Type* t4, llvm::Type* t5) {
133  return recordType(list(t0, t1, t2, t3, t4, t5));
134 }
135 
136 inline llvm::StructType* recordType(llvm::Type* t0, llvm::Type* t1, llvm::Type* t2, llvm::Type* t3, llvm::Type* t4, llvm::Type* t5, llvm::Type* t6) {
137  return recordType(list(t0, t1, t2, t3, t4, t5, t6));
138 }
139 
140 inline llvm::FunctionType* functionType(const Types& argTys, llvm::Type* rty) {
141  return llvm::FunctionType::get(rty, argTys, false);
142 }
143 
144 inline llvm::StructType* varArrayType(llvm::Type* elemty, size_t sz = 1) {
145  return recordType(longType(), arrayType(elemty, sz));
146 }
147 
148 // casting
149 inline llvm::Value* cast(llvm::IRBuilder<>* b, llvm::Type* ty, llvm::Value* v) {
150  return b->CreateBitCast(v, ty);
151 }
152 
153 inline llvm::Constant* ccast(llvm::Type* ty, llvm::Constant* v) {
154  return llvm::ConstantExpr::getBitCast(v, ty);
155 }
156 
157 // constant utilities
158 inline llvm::Constant* cvalue(bool x) {
159  return llvm::Constant::getIntegerValue(boolType(), llvm::APInt(1, x ? 1 : 0, false));
160 }
161 
162 inline llvm::Constant* cvalue(char x) {
163  return llvm::Constant::getIntegerValue(charType(), llvm::APInt(8, x, true));
164 }
165 
166 inline llvm::Constant* cvalue(unsigned char x) {
167  return llvm::Constant::getIntegerValue(charType(), llvm::APInt(8, x, false));
168 }
169 
170 inline llvm::Constant* cvalue(short x) {
171  return llvm::Constant::getIntegerValue(shortType(), llvm::APInt(16, x, false));
172 }
173 
174 inline llvm::Constant* cvalue(int x) {
175  return llvm::Constant::getIntegerValue(intType(), llvm::APInt(32, x, true));
176 }
177 
178 inline llvm::Constant* cvalue(unsigned int x) {
179  return llvm::Constant::getIntegerValue(intType(), llvm::APInt(32, x, true));
180 }
181 
182 inline llvm::Constant* cvalue(long x) {
183  return llvm::Constant::getIntegerValue(longType(), llvm::APInt(64, x, true));
184 }
185 
186 inline llvm::Constant* cvalue(float x) {
187  return llvm::ConstantFP::get(context(), llvm::APFloat(x));
188 }
189 
190 inline llvm::Constant* cvalue(double x) {
191  return llvm::ConstantFP::get(context(), llvm::APFloat(x));
192 }
193 
194 // constant int utilities (different than constants to LLVM!)
195 inline llvm::ConstantInt* civalue(bool x) {
196  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 1), (uint64_t)(x ? 1 : 0));
197 }
198 
199 inline llvm::ConstantInt* civalue(char x) {
200  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 8), (uint64_t)x);
201 }
202 
203 inline llvm::ConstantInt* civalue(unsigned char x) {
204  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 8), (uint64_t)x);
205 }
206 
207 inline llvm::ConstantInt* civalue(short x) {
208  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 16), (uint64_t)x);
209 }
210 
211 inline llvm::ConstantInt* civalue(int x) {
212  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 32), (uint64_t)x);
213 }
214 
215 inline llvm::ConstantInt* civalue(unsigned int x) {
216  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 32), (uint64_t)x);
217 }
218 
219 inline llvm::ConstantInt* civalue(long x) {
220  return llvm::ConstantInt::get(llvm::IntegerType::get(context(), 64), (uint64_t)x);
221 }
222 
223 // an intermediate representation for records
224 typedef std::pair<std::string, llvm::Value*> FieldValue;
225 typedef std::vector<FieldValue> RecordValue;
226 
227 typedef std::pair<std::string, llvm::Constant*> ConstFieldValue;
228 typedef std::vector<ConstFieldValue> ConstRecordValue;
229 
230 // add any standard settings to global variables that we need
231 inline llvm::GlobalVariable* prepgv(llvm::GlobalVariable* gv, unsigned int align = sizeof(void*)) {
232  gv->setAlignment(align);
233  return gv;
234 }
235 
236 // constant :: Value -> Bool -> Const
237 // try to extract a constant from a value (either by value or reference)
238 inline llvm::Constant* constant(llvm::Value* v, bool globalPtrRefs) {
239  if (llvm::GlobalVariable* gv = llvm::dyn_cast<llvm::GlobalVariable>(v)) {
240  if (gv->isConstant()) {
241  if (globalPtrRefs) {
242  return gv;
243  } else {
244  return gv->getInitializer();
245  }
246  } else {
247  return 0;
248  }
249  } else if (llvm::Constant* c = llvm::dyn_cast<llvm::Constant>(v)) {
250  return c;
251  } else {
252  return 0;
253  }
254 }
255 
256 // liftAsGlobalRef :: Constant -> Constant
257 // convert a constant to a global reference to the constant
258 inline llvm::Constant* liftAsGlobalRef(llvm::Module* m, llvm::Constant* c) {
259  return
260  new llvm::GlobalVariable(
261  *m,
262  c->getType(),
263  true,
264  llvm::GlobalVariable::InternalLinkage,
265  c
266  );
267 }
268 
269 // varArrayConstants :: [Value] -> Bool -> [Const]
270 // try to extract constants from a set of compiled values -- if even one value is not constant, fail by returning an empty list
271 inline Constants varArrayConstants(const Values& vs, bool globalPtrRefs) {
272  Constants r;
273  for (Values::const_iterator v = vs.begin(); v != vs.end(); ++v) {
274  if (llvm::Constant* c = constant(*v, globalPtrRefs)) {
275  r.push_back(c);
276  } else {
277  return Constants();
278  }
279  }
280  return r;
281 }
282 
283 inline Constants liftAsGlobalRefs(llvm::Module* m, const Constants& cs) {
284  Constants r;
285  for (auto c : cs) {
286  r.push_back(liftAsGlobalRef(m, c));
287  }
288  return r;
289 }
290 
291 inline llvm::Constant* constArray(llvm::Module* m, const Constants& cs, llvm::Type* elemTy, bool boxAsGlobalRefs = false) {
292  llvm::ArrayType* aty = arrayType(elemTy, cs.size());
293  llvm::StructType* saty = varArrayType(elemTy, cs.size());
294 
295  long arrayLen = cs.size();
296  Constants ncs = elemTy->isVoidTy() ? Constants() : cs;
297 
298  if (boxAsGlobalRefs) {
299  ncs = liftAsGlobalRefs(m, ncs);
300  }
301 
302  return llvm::ConstantStruct::get(saty, list<llvm::Constant*>(cvalue(arrayLen), llvm::ConstantArray::get(aty, ncs)));
303 }
304 
305 inline llvm::Value* tryMkConstVarArray(llvm::IRBuilder<>* b, llvm::Module* m, llvm::Type* elemTy, const Values& vs, bool globalPtrRefs) {
306  Constants cs = varArrayConstants(vs, globalPtrRefs);
307  if (cs.size() != vs.size()) {
308  return 0;
309  } else {
310  llvm::StructType* saty = varArrayType(elemTy, cs.size());
311  llvm::StructType* caty = varArrayType(elemTy);
312 
313  return
314  cast(b, ptrType(caty),
315  new llvm::GlobalVariable(
316  *m,
317  saty,
318  true,
319  llvm::GlobalVariable::InternalLinkage,
320  constArray(m, cs, elemTy)
321  )
322  );
323  }
324 }
325 
326 inline llvm::Constant* padding(unsigned int len) {
327  Constants pad;
328  for (unsigned int i = 0; i < len; ++i) {
329  pad.push_back(cvalue((unsigned char)0));
330  }
331  return llvm::ConstantArray::get(arrayType(byteType(), len), pad);
332 }
333 
334 inline Constants mergePadding(const Constants& cs, const Record::Members& ms) {
335  Constants r;
336  size_t i = 0;
337  Record::Members::const_iterator m = ms.begin();
338  while (m != ms.end()) {
339  if (m->field[0] == '.' && m->field[1] == 'p') {
340  size_t plen = 0;
341  if (FixedArray* fa = is<FixedArray>(m->type)) {
342  long asz = fa->requireLength();
343  plen = asz < 0 ? 0 : ((size_t)asz);
344  } else {
345  throw std::runtime_error("Cannot derive padding for pad field with non-padding type (internal error)");
346  }
347  r.push_back(padding(plen));
348  } else {
349  r.push_back(cs[i]);
350  ++i;
351  }
352  ++m;
353  }
354  return r;
355 }
356 
357 inline Types types(const Constants& cs) {
358  Types r;
359  for (unsigned int c = 0; c < cs.size(); ++c) {
360  r.push_back(cs[c]->getType());
361  }
362  return r;
363 }
364 
365 typedef std::pair<std::vector<std::string>, Values> UnzRecValues;
366 
367 inline Constants recordUZConstants(const UnzRecValues& rps, const Record* rty) {
368  Constants r;
369  for (size_t i = 0; i < rps.second.size(); ++i) {
370  if (llvm::Constant* c = constant(rps.second[i], is<Array>(rty->member(rps.first[i])))) { // not pretty ...
371  r.push_back(c);
372  } else {
373  return Constants();
374  }
375  }
376  return r;
377 }
378 
379 llvm::Type* toLLVM(const MonoTypePtr&, bool);
380 
381 inline Constants liftArraysAsGlobals(llvm::Module* m, const Constants& cs, const MonoTypes& tys) {
382  Constants r;
383  for (size_t i = 0; i < std::min<size_t>(cs.size(), tys.size()); ++i) {
384  if (is<Array>(tys[i])) {
385  r.push_back(llvm::ConstantExpr::getBitCast(liftAsGlobalRef(m, cs[i]), toLLVM(tys[i], true)));
386  } else {
387  r.push_back(cs[i]);
388  }
389  }
390  return r;
391 }
392 
393 inline llvm::Constant* constantRecord(llvm::Module*, const Constants& cs, const Record* rty) {
394  return llvm::ConstantStruct::getAnon(mergePadding(cs, rty->alignedMembers()), true);
395 }
396 
397 inline llvm::Value* tryMkConstRecord(llvm::IRBuilder<>*, llvm::Module* m, const RecordValue& rv, const Record* rty) {
398  Constants crv = recordUZConstants(unzip(rv), rty);
399  if (crv.size() != rv.size()) {
400  return 0;
401  } else {
402  Constants pcs = mergePadding(crv, rty->alignedMembers());
403  llvm::StructType* sty = packedRecordType(types(pcs));
404 
405  return prepgv(
406  new llvm::GlobalVariable(
407  *m,
408  sty,
409  true,
410  llvm::GlobalVariable::InternalLinkage,
411  llvm::ConstantStruct::getAnon(pcs, true)
412  ),
413  1
414  );
415  }
416 }
417 
418 // pointer / GEP utilities
419 inline llvm::Value* offset(llvm::IRBuilder<>* b, llvm::Value* p, llvm::Value* o0) {
420  std::vector<llvm::Value*> idxs;
421  idxs.push_back(o0);
422  return b->CreateGEP(p, idxs);
423 }
424 
425 inline llvm::Value* offset(llvm::IRBuilder<>* b, llvm::Value* p, int o0) {
426  return offset(b, p, cvalue(o0));
427 }
428 
429 inline llvm::Value* offset(llvm::IRBuilder<>* b, llvm::Value* p, int o0, int o1) {
430  std::vector<llvm::Value*> idxs;
431  idxs.push_back(cvalue(o0));
432  idxs.push_back(cvalue(o1));
433  return b->CreateGEP(p, idxs);
434 }
435 
436 inline llvm::Value* offset(llvm::IRBuilder<>* b, llvm::Value* p, int o0, llvm::Value* o1) {
437  std::vector<llvm::Value*> idxs;
438  idxs.push_back(cvalue(o0));
439  idxs.push_back(o1);
440  return b->CreateGEP(p, idxs);
441 }
442 
443 inline llvm::Value* structOffset(llvm::IRBuilder<>* b, llvm::Value* p, unsigned int fieldOffset) {
444 #if LLVM_VERSION_MINOR == 7
445  // don't pass nullptr? (http://reviews.llvm.org/rL233938)
446  return b->CreateStructGEP(nullptr, p, fieldOffset);
447 #elif LLVM_VERSION_MINOR >= 8
448  return b->CreateStructGEP(((llvm::PointerType*)p->getType())->getElementType(), p, fieldOffset);
449 #else
450  return b->CreateStructGEP(p, fieldOffset);
451 #endif
452 }
453 
454 #if LLVM_VERSION_MINOR >= 6
455 inline llvm::ExecutionEngine* makeExecutionEngine(llvm::Module* m, llvm::SectionMemoryManager* smm) {
456  std::string err;
457  llvm::ExecutionEngine* ee =
458  llvm::EngineBuilder(std::unique_ptr<llvm::Module>(m))
459  .setErrorStr(&err)
460  .setMCJITMemoryManager(std::unique_ptr<llvm::SectionMemoryManager>(smm))
461  .create();
462 
463  if (!ee) {
464  throw std::runtime_error("Internal error, failed to allocate execution engine with error: " + err);
465  }
466  return ee;
467 }
468 #elif LLVM_VERSION_MINOR == 3 or LLVM_VERSION_MINOR == 5
469 inline llvm::ExecutionEngine* makeExecutionEngine(llvm::Module* m, llvm::SectionMemoryManager*) {
470  std::string err;
471  llvm::ExecutionEngine* ee =
472  llvm::EngineBuilder(m)
473  .setErrorStr(&err)
474  .create();
475 
476  if (!ee) {
477  throw std::runtime_error("Internal error, failed to allocate execution engine with error: " + err);
478  }
479  return ee;
480 }
481 #endif
482 
483 inline llvm::Function* externDecl(llvm::Function* remoteFn, llvm::Module* thisModule) {
484  if (llvm::Function* ef = thisModule->getFunction(remoteFn->getName())) {
485  return ef;
486  } else {
487  return llvm::Function::Create(remoteFn->getFunctionType(), llvm::Function::ExternalLinkage, remoteFn->getName(), thisModule);
488  }
489 }
490 
491 const size_t FUNCTION_SIZE_THRESHOLD = 64;
492 inline llvm::Function* cloneFunction(llvm::Function *f, llvm::Module *targetMod) {
493  using namespace llvm;
494  if (f->isDeclaration())
495  return nullptr;
496 
497  // By counting the number of instructions, we can have a rough estimation of the function size,
498  // based on which we can decide whether to "copy" the function between modules. The actual decision
499  // of inlining is up to LLVM.
500  auto iInst = llvm::inst_begin(f);
501  auto iInstEnd = llvm::inst_end(f);
502  for (size_t i = 0; i < FUNCTION_SIZE_THRESHOLD; i++) {
503  if (++iInst == iInstEnd)
504  break;
505  }
506  if (iInst != iInstEnd)
507  return nullptr;
508 
509  ValueToValueMapTy vmap;
510  SmallVector<ReturnInst*, 8> returns;
511  Function *newF = Function::Create(f->getFunctionType(), f->getLinkage(), f->getName(), targetMod);
512  Function::arg_iterator iDest = newF->arg_begin();
513  for (const Argument &arg : f->args()) {
514  iDest->setName(arg.getName());
515  vmap[&arg] = &*iDest++;
516  }
517 
518  CloneFunctionInto(newF, f, vmap, false, returns);
519  return newF;
520 }
521 
522 inline llvm::Value* fncall(llvm::IRBuilder<>* b, llvm::Value* vfn, const Values& args) {
523 #if LLVM_VERSION_MINOR >= 6
524  llvm::Module* thisMod = b->GetInsertBlock()->getParent()->getParent();
525 
526  llvm::Function* fn = llvm::dyn_cast<llvm::Function>(vfn);
527  if (!fn || fn->getParent() == thisMod) {
528  // same module or local variable, all is well
529  return b->CreateCall(vfn, args);
530  } else {
531  // looks like we're trying to make a call to a function in another module
532  if (auto newF = cloneFunction(fn, thisMod))
533  return b->CreateCall(newF, args);
534  return b->CreateCall(externDecl(fn, thisMod), args);
535  }
536 #else
537  return b->CreateCall(vfn, args);
538 #endif
539 }
540 
541 inline llvm::Value* fncall(llvm::IRBuilder<>* b, llvm::Value* fn, llvm::Value* arg) {
542  return fncall(b, fn, list(arg));
543 }
544 
545 }
546 
547 #endif
std::vector< llvm::Value * > Values
Definition: jitcc.H:216
llvm::Value * tryMkConstRecord(llvm::IRBuilder<> *, llvm::Module *m, const RecordValue &rv, const Record *rty)
Definition: llvm.H:397
Types types(const Constants &cs)
Definition: llvm.H:357
const size_t FUNCTION_SIZE_THRESHOLD
Definition: llvm.H:491
T align(T x, T m)
Definition: ptr.H:98
Constants liftArraysAsGlobals(llvm::Module *m, const Constants &cs, const MonoTypes &tys)
Definition: llvm.H:381
llvm::Type * voidType()
Definition: llvm.H:58
llvm::PointerType * ptrType(llvm::Type *ty)
Definition: llvm.H:94
llvm::Constant * padding(unsigned int len)
Definition: llvm.H:326
llvm::StructType * recordType(const Types &tys)
Definition: llvm.H:108
llvm::Value * cast(llvm::IRBuilder<> *b, llvm::Type *ty, llvm::Value *v)
Definition: llvm.H:149
llvm::GlobalVariable * prepgv(llvm::GlobalVariable *gv, unsigned int align=sizeof(void *))
Definition: llvm.H:231
llvm::Type * boolType()
Definition: llvm.H:62
Definition: boot.H:7
Definition: type.H:423
Constants recordUZConstants(const UnzRecValues &rps, const Record *rty)
Definition: llvm.H:367
llvm::StructType * packedRecordType(const Types &tys)
Definition: llvm.H:104
llvm::Constant * liftAsGlobalRef(llvm::Module *m, llvm::Constant *c)
Definition: llvm.H:258
llvm::Value * offset(llvm::IRBuilder<> *b, llvm::Value *p, llvm::Value *o0)
Definition: llvm.H:419
std::pair< std::vector< L >, std::vector< R > > unzip(const std::vector< std::pair< L, R > > &ps)
Definition: array.H:238
llvm::LLVMContext & context()
Definition: llvm.H:49
Constants mergePadding(const Constants &cs, const Record::Members &ms)
Definition: llvm.H:334
llvm::Type * floatType()
Definition: llvm.H:86
llvm::Type * intType()
Definition: llvm.H:78
MonoType::ptr MonoTypePtr
Definition: type.H:71
llvm::StructType * varArrayType(llvm::Type *elemty, size_t sz=1)
Definition: llvm.H:144
llvm::FunctionType * functionType(const Types &argTys, llvm::Type *rty)
Definition: llvm.H:140
llvm::Type * byteType()
Definition: llvm.H:70
llvm::Type * shortType()
Definition: llvm.H:74
llvm::Type * doubleType()
Definition: llvm.H:90
T * get(variant< Ctors... > &v)
Definition: variant.H:156
llvm::Constant * ccast(llvm::Type *ty, llvm::Constant *v)
Definition: llvm.H:153
std::pair< std::string, llvm::Value * > FieldValue
Definition: llvm.H:224
Definition: type.H:335
llvm::ConstantInt * civalue(bool x)
Definition: llvm.H:195
std::vector< ConstFieldValue > ConstRecordValue
Definition: llvm.H:228
llvm::Value * tryMkConstVarArray(llvm::IRBuilder<> *b, llvm::Module *m, llvm::Type *elemTy, const Values &vs, bool globalPtrRefs)
Definition: llvm.H:305
const Members & alignedMembers() const
Definition: type.C:1361
std::pair< std::vector< std::string >, Values > UnzRecValues
Definition: llvm.H:365
llvm::Value * toLLVM(jitcc *, const ExprPtr &exp)
Definition: cexpr.C:617
llvm::Constant * cvalue(bool x)
Definition: llvm.H:158
llvm::Constant * constArray(llvm::Module *m, const Constants &cs, llvm::Type *elemTy, bool boxAsGlobalRefs=false)
Definition: llvm.H:291
std::vector< T > list()
Definition: array.H:25
size_t r(const reader::MetaData &md, size_t o, T *t)
Definition: storage.H:1730
ExprPtr fncall(const ExprPtr &f, const Exprs &args, const LexicalAnnotation &la)
Definition: expr.H:845
ExprPtr fn(const str::seq &vns, const ExprPtr &b, const LexicalAnnotation &la)
Definition: expr.H:837
std::vector< FieldValue > RecordValue
Definition: llvm.H:225
const MonoTypePtr & member(const std::string &mn) const
Definition: type.C:1316
std::pair< std::string, llvm::Constant * > ConstFieldValue
Definition: llvm.H:227
std::vector< Member > Members
Definition: type.H:435
llvm::Type * longType()
Definition: llvm.H:82
std::vector< MonoTypePtr > MonoTypes
Definition: type.H:72
llvm::ArrayType * arrayType(llvm::Type *ty, size_t sz)
Definition: llvm.H:98
llvm::Function * cloneFunction(llvm::Function *f, llvm::Module *targetMod)
Definition: llvm.H:492
llvm::Function * externDecl(llvm::Function *remoteFn, llvm::Module *thisModule)
Definition: llvm.H:483
llvm::Constant * constantRecord(llvm::Module *, const Constants &cs, const Record *rty)
Definition: llvm.H:393
Constants liftAsGlobalRefs(llvm::Module *m, const Constants &cs)
Definition: llvm.H:283
LexicalAnnotation m(const YYLTYPE &p)
Definition: hexpr.parse.C:127
std::vector< llvm::Type * > Types
Definition: llvm.H:53
std::string pad(size_t n)
Definition: str.C:50
std::vector< llvm::Constant * > Constants
Definition: llvm.H:54
llvm::Type * charType()
Definition: llvm.H:66
Constants varArrayConstants(const Values &vs, bool globalPtrRefs)
Definition: llvm.H:271
ExprPtr constant(bool x, const LexicalAnnotation &la)
Definition: expr.H:672
llvm::Value * structOffset(llvm::IRBuilder<> *b, llvm::Value *p, unsigned int fieldOffset)
Definition: llvm.H:443