Compile simple IR::New nodes

This commit is contained in:
Roberto Raggi 2012-06-06 10:08:06 +02:00
parent 3631bac985
commit ad9816514f
3 changed files with 47 additions and 4 deletions

View File

@ -165,4 +165,9 @@ void __qmljs_llvm_call_activation_property(Context *context, Value *result, Stri
__qmljs_call_activation_property(context, result, name, args, argc);
}
void __qmljs_llvm_construct_activation_property(Context *context, Value *result, String *name, Value *args, int argc)
{
__qmljs_construct_activation_property(context, result, name, args, argc);
}
} // extern "C"

View File

@ -414,8 +414,45 @@ void LLVMInstructionSelection::visitCall(IR::Call *e)
void LLVMInstructionSelection::visitNew(IR::New *e)
{
llvm::Value *base = getLLVMValue(e->base);
Q_UNIMPLEMENTED();
llvm::Value *func = 0;
llvm::Value *base = 0;
if (IR::Temp *t = e->base->asTemp()) {
base = getLLVMTemp(t);
func = _llvmModule->getFunction("__qmljs_llvm_construct_value");
} else if (IR::Name *n = e->base->asName()) {
if (n->id) {
llvm::Value *str = getStringPtr(*n->id);
base = CreateCall2(_llvmModule->getFunction("__qmljs_llvm_get_identifier"),
_llvmFunction->arg_begin(), str);
func = _llvmModule->getFunction("__qmljs_llvm_construct_activation_property");
}
}
int argc = 0;
for (IR::ExprList *it = e->args; it; it = it->next) {
++argc;
}
llvm::Value *args = 0;
if (argc)
args = newLLVMTemp(_valueTy, getInt32(argc));
else
args = llvm::Constant::getNullValue(_valueTy->getPointerTo());
int i = 0;
for (IR::ExprList *it = e->args; it; it = it->next) {
llvm::Value *arg = getLLVMValue(it->expr);
CreateStore(arg, CreateConstGEP1_32(args, i++));
}
if (func) {
llvm::Value *result = newLLVMTemp(_valueTy);
CreateStore(llvm::Constant::getNullValue(_valueTy), result);
CreateCall5(func, _llvmFunction->arg_begin(), result, base, args, getInt32(argc));
_llvmValue = CreateLoad(result);
} else {
Q_UNIMPLEMENTED();
}
}
void LLVMInstructionSelection::visitSubscript(IR::Subscript *)

View File

@ -4,11 +4,12 @@ var b = 2
var c = 10
var d = 100
for (i = 0; i < 1000000; i = i + 1) {
var d1 = new Date
for (var i = 0; i < 1000000; i = i + 1) {
if (a == 1)
d = d + a + b * c
else
d = 321
}
print("the result is", d)
print("the result is", d, "done in", new Date - d1)