llvm binding update

pull/81/head
Dibyendu Majumdar 9 years ago
parent 8dbc144837
commit 71de79ae8e

@ -125,6 +125,8 @@ The following table lists the Lua LLVM api functions available.
| Adds a basic block to the end |
| ``arg(position) -> LLVMvalue`` |
| Returns the argument at position; position >= 1; returns ``nil`` if argument not available |
| ``alloca(type[, name [,arraysize]]) -> LLVMinstruction`` |
| Creates a variable in the first block of the function |
+----------------------------------------------------------------------------------------------+
| **LLVMirbuilder methods** |
+----------------------------------------------------------------------------------------------+
@ -141,7 +143,21 @@ The following table lists the Lua LLVM api functions available.
| ``condbr(vavlue, true_block, false_block) -> LLVMinstruction`` |
| Emit a conditional branch |
| |
| Binary Operators of the form ``op(value1, value2) -> value``. |
| **GEP Operators** |
| |
| ``gep(value, {offsets}) -> LLVMvalue`` |
| getelementptr to obtain ptr to an array or struct element |
| ``inboundsgep(value, {offsets}) -> LLVMvalue`` |
| inbounds version of getelementptr |
| |
| **Memory Operators** |
| |
| ``load(ptr) -> LLVMinstruction`` |
| Loads the value at ptr |
| ``store(value, ptr) -> LLVMinstruction`` |
| Stores the value to ptr |
| |
| **Binary Operators of the form ``op(value1, value2) -> LLVMvalue``** |
| |
| * ``icmpeq`` |
| * ``icmpne`` |
@ -186,18 +202,13 @@ The following table lists the Lua LLVM api functions available.
| * ``fdiv`` |
| * ``frem`` |
| |
| Unary Operators of the form ``op(value) -> value``. |
| **Unary Operators of the form ``op(value) -> LLVMvalue``** |
| |
| * ``not`` |
| * ``neg`` |
| * ``fneg`` |
| |
| GEP Operators |
| |
| * ``gep`` |
| * ``inboundsgep`` |
| |
| Conversion Operators |
| **Conversion Operators of the form ``op(value,type) -> LLVMvalue``** |
| |
| * ``trunc`` |
| * ``zext`` |
@ -218,10 +229,4 @@ The following table lists the Lua LLVM api functions available.
| * ``truncorbitcast`` |
| * ``pointercast`` |
| * ``fpcast`` |
| |
| Memory Operators |
| |
| * ``alloca`` |
| * ``load`` |
| * ``store`` |
+----------------------------------------------------------------------------------------------+

@ -1078,13 +1078,19 @@ static llvm::Type *get_type(lua_State *L, int idx) {
return nullptr;
}
static int irbuilder_alloca(lua_State *L) {
IRBuilderHolder *builder = check_LLVM_irbuilder(L, 1);
static int func_alloca(lua_State *L) {
llvm::Function *func = get_function(L, 1);
llvm::Type *ty = get_type(L, 2);
llvm::Value *arraysize = nullptr;
const char *name = nullptr;
if (lua_gettop(L) >= 3)
arraysize = get_value(L, 3);
llvm::Instruction *inst = builder->builder->CreateAlloca(ty, arraysize);
name = luaL_checkstring(L, 3);
if (lua_gettop(L) >= 4)
arraysize = get_value(L, 4);
llvm::BasicBlock *block = func->getBasicBlockList().begin();
luaL_argcheck(L, block != nullptr, 1, "No basic block in function");
llvm::IRBuilder<> builder(block, block->begin());
llvm::Instruction *inst = builder.CreateAlloca(ty, arraysize, name);
alloc_LLVM_instruction(L, inst);
return 1;
}
@ -1243,11 +1249,13 @@ static const luaL_Reg main_function_methods[] = {
{"extern", func_addextern},
{"arg", func_getarg},
{"module", func_getmodule},
{"alloca", func_alloca },
{NULL, NULL}};
static const luaL_Reg function_methods[] = {
{"appendblock", func_append_basicblock},
{"arg", func_getarg},
{"alloca", func_alloca },
{NULL, NULL}};
static const luaL_Reg context_methods[] = {
@ -1335,7 +1343,6 @@ static const luaL_Reg irbuilder_methods[] = {
{"truncorbitcast", irbuilder_TruncOrBitCast},
{"pointercast", irbuilder_PointerCast},
{"fpcast", irbuilder_FPCast},
{"alloca", irbuilder_alloca},
{"load", irbuilder_load},
{"store", irbuilder_store},
{NULL, NULL}};

Loading…
Cancel
Save