[vmkit-commits] [vmkit] r198247 - Unify access for locals and stack
Gael Thomas
gael.thomas at lip6.fr
Mon Dec 30 12:45:31 PST 2013
Author: gthomas
Date: Mon Dec 30 14:45:31 2013
New Revision: 198247
URL: http://llvm.org/viewvc/llvm-project?rev=198247&view=rev
Log:
Unify access for locals and stack
Modified:
vmkit/branches/mcjit/include/j3/j3codegenvar.h
vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc
Modified: vmkit/branches/mcjit/include/j3/j3codegenvar.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegenvar.h?rev=198247&r1=198246&r2=198247&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3codegenvar.h (original)
+++ vmkit/branches/mcjit/include/j3/j3codegenvar.h Mon Dec 30 14:45:31 2013
@@ -14,6 +14,8 @@ namespace j3 {
class J3CodeGenVar {
void killUnused(llvm::AllocaInst** stack, bool isObj);
+
+ llvm::AllocaInst** stackOf(llvm::Type* t);
public:
J3CodeGen* codeGen;
llvm::AllocaInst** intStack;
Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc?rev=198247&r1=198246&r2=198247&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc Mon Dec 30 14:45:31 2013
@@ -97,58 +97,31 @@ void J3CodeGenVar::drop(uint32_t n) {
topStack -= n;
}
-void J3CodeGenVar::setAt(llvm::Value* value, uint32_t idx) {
- //if(idx >= nbLocals + maxStack)
- //J3::classFormatError(cl, L"bad index %lu", idx);
- llvm::Type* t = value->getType();
- llvm::AllocaInst** stack;
-
+llvm::AllocaInst** J3CodeGenVar::stackOf(llvm::Type* t) {
if(t->isIntegerTy(64)) {
- stack = longStack;
+ return longStack;
} else if(t->isIntegerTy()) {
- stack = intStack;
+ return intStack;
} else if(t->isFloatTy()) {
- stack = floatStack;
+ return floatStack;
} else if(t->isDoubleTy()) {
- stack = doubleStack;
+ return doubleStack;
} else if(t->isPointerTy()) {
- stack = refStack;
- } else
- J3::internalError(L"should not happen");
-
- // fprintf(stderr, "setAt[%u]: ", idx);
- // value->dump();
- // fprintf(stderr, "\n");
+ return refStack;
+ }
+
+ J3::internalError(L"should not happen");
+}
+void J3CodeGenVar::setAt(llvm::Value* value, uint32_t idx) {
+ llvm::Type* t = value->getType();
metaStack[idx] = t;
-
- codeGen->builder->CreateStore(value, stack[idx]);
+ codeGen->builder->CreateStore(value, stackOf(t)[idx]);
}
llvm::Value* J3CodeGenVar::at(uint32_t idx) {
- //if(idx >= nbLocals + maxStack)
- //vm->classFormatError(cl, L"bad index %lu", idx);
llvm::Type* t = metaStack[idx];
- llvm::Value* res;
-
- if(t->isIntegerTy(64)) {
- res = codeGen->builder->CreateLoad(longStack[idx]);
- } else if(t->isIntegerTy()) {
- res = codeGen->builder->CreateLoad(intStack[idx]);
- } else if(t->isFloatTy()) {
- res = codeGen->builder->CreateLoad(floatStack[idx]);
- } else if(t->isDoubleTy()) {
- res = codeGen->builder->CreateLoad(doubleStack[idx]);
- } else if(t->isPointerTy()) {
- res = codeGen->builder->CreateLoad(refStack[idx]);
- } else
- J3::internalError(L"should not happen");
-
- // fprintf(stderr, "top: ");
- // res->dump();
- // fprintf(stderr, "\n");
-
- return res;
+ return codeGen->builder->CreateLoad(stackOf(t)[idx]);
}
void J3CodeGenVar::push(llvm::Value* value) {
More information about the vmkit-commits
mailing list