Пример #1
0
llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name)
{
    LLGlobalVariable* gv = target->getNamedGlobal(name);
    if (gv) {
        return gv;
    }

    if (noruntime) {
        error("No implicit runtime calls allowed with -noruntime option enabled");
        fatal();
    }

    if (!M) {
        LLVM_D_InitRuntime();
    }

    LLGlobalVariable* g = M->getNamedGlobal(name);
    if (!g) {
        error("Runtime global '%s' was not found", name);
        fatal();
        //return NULL;
    }

    LLPointerType* t = g->getType();
    return new LLGlobalVariable(*target, t->getElementType(), g->isConstant(),
                                g->getLinkage(), NULL, g->getName());
}
Пример #2
0
LLConstant *DtoGEPi(LLConstant *ptr, unsigned i0, unsigned i1) {
  LLPointerType *p = isaPointer(ptr);
  (void)p;
  assert(p && "GEP expects a pointer type");
  LLValue *indices[] = {DtoConstUint(i0), DtoConstUint(i1)};
  return llvm::ConstantExpr::getGetElementPtr(
      p->getElementType(), ptr, indices, /* InBounds = */ true);
}
Пример #3
0
LLValue* DtoGEPi1(LLValue* ptr, unsigned i, const char* var, llvm::BasicBlock* bb)
{
    LLPointerType* p = isaPointer(ptr);
    assert(p && "GEP expects a pointer type");
    return llvm::GetElementPtrInst::Create(
#if LDC_LLVM_VER >= 307
        p->getElementType(),
#endif
        ptr, DtoConstUint(i), var, bb ? bb : gIR->scopebb());
}
Пример #4
0
LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1)
{
    LLPointerType* p = isaPointer(ptr);
    assert(p && "GEP expects a pointer type");
    LLValue* v[] = { DtoConstUint(i0), DtoConstUint(i1) };
    return llvm::ConstantExpr::getGetElementPtr(
#if LDC_LLVM_VER >= 307
        p->getElementType(),
#endif
        ptr, v, true);
}
Пример #5
0
LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb)
{
    LLPointerType* p = isaPointer(ptr);
    assert(p && "GEP expects a pointer type");
    LLValue* v[] = { i0, i1 };
    return llvm::GetElementPtrInst::Create(
#if LDC_LLVM_VER >= 307
        p->getElementType(),
#endif
        ptr, v, var, bb ? bb : gIR->scopebb());
}
Пример #6
0
llvm::GlobalVariable *getRuntimeGlobal(Loc &loc, llvm::Module &target,
                                       const char *name) {
  LLGlobalVariable *gv = target.getNamedGlobal(name);
  if (gv) {
    return gv;
  }

  checkForImplicitGCCall(loc, name);

  if (!M) {
    initRuntime();
  }

  LLGlobalVariable *g = M->getNamedGlobal(name);
  if (!g) {
    error(loc, "Runtime global '%s' was not found", name);
    fatal();
    // return NULL;
  }

  LLPointerType *t = g->getType();
  return getOrCreateGlobal(loc, target, t->getElementType(), g->isConstant(),
                           g->getLinkage(), nullptr, g->getName());
}