Пример #1
0
  v8::Handle<v8::Value> IRBuilder::CreateGlobalStringPtr(const v8::Arguments& args)
  {
    HandleScope scope;

    FALLBACK_EMPTY_UTF8_ARG(0, val);
    FALLBACK_EMPTY_UTF8_ARG(1, name);

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(IRBuilder::builder.CreateGlobalStringPtr(*val, *name)));
    return scope.Close(result);
  }
Пример #2
0
 ejsval
 IRBuilder_createOr(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     REQ_LLVM_VAL_ARG(0, lhs);
     REQ_LLVM_VAL_ARG(1, rhs);
     FALLBACK_EMPTY_UTF8_ARG(2, name);
     return Value_new (_llvm_builder.CreateOr(lhs, rhs, name));
 }
Пример #3
0
    ejsval
    IRBuilder_createGlobalStringPtr(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_UTF8_ARG(0, val);
        FALLBACK_EMPTY_UTF8_ARG(1, name);

        return Value_new (_llvm_builder.CreateGlobalStringPtr(val, name));
    }
Пример #4
0
 ejsval
 IRBuilder_createBitCast(ejsval env, ejsval _this, int argc, ejsval *args)
 {
     REQ_LLVM_VAL_ARG(0, V);
     REQ_LLVM_TYPE_ARG(1, dest_ty);
     FALLBACK_EMPTY_UTF8_ARG(2, name);
     return Value_new (_llvm_builder.CreateBitCast(V, dest_ty, name));
 }
Пример #5
0
    ejsval
    IRBuilder_createLoad(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, val);
        FALLBACK_EMPTY_UTF8_ARG(1, name);

        return LoadInst_new (_llvm_builder.CreateLoad(val, name));
    }
Пример #6
0
    ejsval
    IRBuilder_createAlloca(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_TYPE_ARG(0, ty);
        FALLBACK_EMPTY_UTF8_ARG(1, name);

        return AllocaInst_new (_llvm_builder.CreateAlloca(ty, 0, name));
    }
Пример #7
0
    ejsval
    IRBuilder_createExtractValue(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, val);
        REQ_INT_ARG(1, idx);
        FALLBACK_EMPTY_UTF8_ARG(2, name);

        return Value_new (_llvm_builder.CreateExtractValue(val, idx, name));
    }
Пример #8
0
    ejsval
    IRBuilder_createStructGetElementPointer(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, val);
        REQ_INT_ARG(1, idx);
        FALLBACK_EMPTY_UTF8_ARG(2, name);

        return Value_new (_llvm_builder.CreateStructGEP(val, idx, name));
    }
Пример #9
0
    ejsval
    IRBuilder_createICmpULt(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, left);
        REQ_LLVM_VAL_ARG(1, right);
        FALLBACK_EMPTY_UTF8_ARG(2, name);

        return Value_new (_llvm_builder.CreateICmpULT(left, right, name));
    }
Пример #10
0
  v8::Handle<v8::Value> IRBuilder::CreateLoad(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_VAL_ARG(0, val);
    FALLBACK_EMPTY_UTF8_ARG(1, name);
    
    Handle<v8::Value> result = LoadInst::New(IRBuilder::builder.CreateLoad(val, *name));
    return scope.Close(result);
  }
Пример #11
0
  v8::Handle<v8::Value> IRBuilder::CreateAlloca(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_TYPE_ARG(0, ty);
    FALLBACK_EMPTY_UTF8_ARG(1, name);
    
    Handle<v8::Value> result = AllocaInst::New(IRBuilder::builder.CreateAlloca(ty, 0, *name));
    return scope.Close(result);
  }
Пример #12
0
    ejsval
    IRBuilder_createLandingPad(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_TYPE_ARG(0, ty);
        REQ_LLVM_VAL_ARG(1, persFn);
        REQ_INT_ARG(2, num_clauses);
        FALLBACK_EMPTY_UTF8_ARG(3, name);

        return LandingPad_new (_llvm_builder.CreateLandingPad(ty, persFn, num_clauses, name));
    }
Пример #13
0
  v8::Handle<v8::Value> IRBuilder::CreateFPCast(const v8::Arguments& args)
  {
    HandleScope scope;
    REQ_LLVM_VAL_ARG(0,val);
    REQ_LLVM_TYPE_ARG(1,ty);
    FALLBACK_EMPTY_UTF8_ARG(2,name);

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(builder.CreateFPCast(val, ty, *name)));
    return scope.Close(result);
  }
Пример #14
0
    ejsval
    IRBuilder_createSelect(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, C);
        REQ_LLVM_VAL_ARG(1, True);
        REQ_LLVM_VAL_ARG(2, False);
        FALLBACK_EMPTY_UTF8_ARG(3, name);

        return Value_new(_llvm_builder.CreateSelect(C, True, False, name));
    }
Пример #15
0
  v8::Handle<v8::Value> IRBuilder::CreatePhi(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_TYPE_ARG(0, ty);
    REQ_INT_ARG(1, incoming_values);
    FALLBACK_EMPTY_UTF8_ARG(2, name);

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(IRBuilder::builder.CreatePHI(ty, incoming_values, *name)));
    return scope.Close(result);
  }
Пример #16
0
  v8::Handle<v8::Value> IRBuilder::CreateStructGetElementPointer(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_VAL_ARG(0, val);
    REQ_INT_ARG(1, idx);
    FALLBACK_EMPTY_UTF8_ARG(2, name);

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(IRBuilder::builder.CreateStructGEP(val, idx, *name)));
    return scope.Close(result);
  }
Пример #17
0
  v8::Handle<v8::Value> IRBuilder::CreateNswSub(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_VAL_ARG(0, lhs);
    REQ_LLVM_VAL_ARG(1, rhs);
    FALLBACK_EMPTY_UTF8_ARG(2, name);

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(IRBuilder::builder.CreateNSWSub(lhs, rhs, *name)));
    return scope.Close(result);
  }
Пример #18
0
  v8::Handle<v8::Value> IRBuilder::CreateSelect(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_VAL_ARG(0, C);
    REQ_LLVM_VAL_ARG(1, True);
    REQ_LLVM_VAL_ARG(2, False);
    FALLBACK_EMPTY_UTF8_ARG(3, name);

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(IRBuilder::builder.CreateSelect(C, True, False, *name)));
    return scope.Close(result);
  }
Пример #19
0
  v8::Handle<v8::Value> IRBuilder::CreateLandingPad(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_TYPE_ARG(0, ty);
    REQ_LLVM_VAL_ARG(1, persFn);
    REQ_INT_ARG(2, num_clauses);
    FALLBACK_EMPTY_UTF8_ARG(3, name);

    Handle<v8::Value> result = LandingPad::New(IRBuilder::builder.CreateLandingPad(ty, persFn, num_clauses, *name));
    return scope.Close(result);
  }
Пример #20
0
    ejsval
    IRBuilder_createPhi(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        abort();
#if notyet
        REQ_LLVM_TYPE_ARG(0, ty);
        REQ_INT_ARG(1, incoming_values);
        FALLBACK_EMPTY_UTF8_ARG(2, name);

        ejsval rv = Value_new (_llvm_builder.CreatePHI(ty, incoming_values, name));
        free (name);
        return rv;
#endif
    }
Пример #21
0
    ejsval
    IRBuilder_createInBoundsGetElementPointer(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, val);
        REQ_ARRAY_ARG(1, idxv);
        FALLBACK_EMPTY_UTF8_ARG(2, name);

        std::vector<llvm::Value*> IdxV;
        for (unsigned i = 0, e = EJSARRAY_LEN(idxv); i != e; ++i) {
            IdxV.push_back (Value_GetLLVMObj(EJSDENSEARRAY_ELEMENTS(idxv)[i]));
            if (IdxV.back() == 0) abort(); // XXX throw an exception here
        }

        return Value_new (_llvm_builder.CreateInBoundsGEP(val, IdxV, name));
    }
Пример #22
0
    ejsval
    IRBuilder_createCall(ejsval env, ejsval _this, int argc, ejsval *args)
    {
        REQ_LLVM_VAL_ARG(0, callee);
        REQ_ARRAY_ARG(1, argv);
        FALLBACK_EMPTY_UTF8_ARG(2, name);

        std::vector<llvm::Value*> ArgsV;
        for (unsigned i = 0, e = EJSARRAY_LEN(argv); i != e; ++i) {
            ArgsV.push_back (Value_GetLLVMObj(EJSDENSEARRAY_ELEMENTS(argv)[i]));
            if (ArgsV.back() == 0) abort(); // XXX throw an exception here
        }

        return Call_new (_llvm_builder.CreateCall(callee, ArgsV, name));
    }
Пример #23
0
  v8::Handle<v8::Value> IRBuilder::CreateInBoundsGetElementPointer(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_VAL_ARG(0, val);
    REQ_ARRAY_ARG(1, idxv);
    FALLBACK_EMPTY_UTF8_ARG(2, name);

    std::vector<llvm::Value*> IdxV;
    for (unsigned i = 0, e = idxv->Length(); i != e; ++i) {
      llvm::Value* idx = Value::GetLLVMObj(idxv->Get(i));
      IdxV.push_back(idx);
      if (IdxV.back() == 0) abort(); // XXX throw an exception here
    }

    Handle<v8::Value> result = Instruction::New(static_cast<llvm::Instruction*>(IRBuilder::builder.CreateInBoundsGEP(val, IdxV, *name)));
    return scope.Close(result);
  }
Пример #24
0
  v8::Handle<v8::Value> IRBuilder::CreateCall(const v8::Arguments& args)
  {
    HandleScope scope;

    REQ_LLVM_VAL_ARG(0, callee);
    REQ_ARRAY_ARG(1, argv);
    FALLBACK_EMPTY_UTF8_ARG(2, name);

    std::vector<llvm::Value*> ArgsV;
    for (unsigned i = 0, e = argv->Length(); i != e; ++i) {
      llvm::Value* arg = Value::GetLLVMObj(argv->Get(i));
      ArgsV.push_back(arg);
      if (ArgsV.back() == 0) abort(); // XXX throw an exception here
    }

    Handle<v8::Value> result = Call::New(IRBuilder::builder.CreateCall(callee, ArgsV, *name));
    return scope.Close(result);
  }