mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-10 13:59:02 +02:00
Added pragma insertelement.
This commit is contained in:
16
gen/toir.cpp
16
gen/toir.cpp
@@ -1015,11 +1015,25 @@ DValue* CallExp::toElem(IRState* p)
|
||||
error("Function %s was declared with pragma extractelement. Because of that its second argument must be an integer literal.", fndecl->toChars());
|
||||
fatal();
|
||||
}
|
||||
LLConstant* idx = static_cast<IntegerExp*>(arguments->data[1])->toConstElem(p);
|
||||
LLValue* idx = exp2->toElem(p)->getRVal();
|
||||
Expression* exp1 = static_cast<Expression*>(arguments->data[0]);
|
||||
LLValue* vec = exp1->toElem(p)->getRVal();
|
||||
return new DImValue(type, p->ir->CreateExtractElement(vec, idx));
|
||||
}
|
||||
// insertelement
|
||||
else if(fndecl->llvmInternal == LLVMinsertelement) {
|
||||
Expression* exp3 = static_cast<Expression*>(arguments->data[2]);
|
||||
if(exp3->op != TOKint64){
|
||||
error("Function %s was declared with pragma extractelement. Because of that its second argument must be an integer literal.", fndecl->toChars());
|
||||
fatal();
|
||||
}
|
||||
LLValue* idx = exp3->toElem(p)->getRVal();
|
||||
Expression* exp1 = static_cast<Expression*>(arguments->data[0]);
|
||||
LLValue* vec = exp1->toElem(p)->getRVal();
|
||||
Expression* exp2 = static_cast<Expression*>(arguments->data[1]);
|
||||
LLValue* scal = exp2->toElem(p)->getRVal();
|
||||
return new DImValue(type, p->ir->CreateInsertElement(vec, scal, idx));
|
||||
}
|
||||
// fence instruction
|
||||
else if (fndecl->llvmInternal == LLVMfence) {
|
||||
if (arguments->dim != 1) {
|
||||
|
||||
Reference in New Issue
Block a user