mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Added pragma extractelement
This commit is contained in:
@@ -274,6 +274,7 @@ Msgtable msgtable[] =
|
||||
{ "no_moduleinfo" },
|
||||
{ "Alloca", "alloca" },
|
||||
{ "Shufflevector", "shufflevector" },
|
||||
{ "Extractelement", "extractelement" },
|
||||
{ "vastart", "va_start" },
|
||||
{ "vacopy", "va_copy" },
|
||||
{ "vaend", "va_end" },
|
||||
|
||||
@@ -116,6 +116,17 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str)
|
||||
return LLVMshufflevector;
|
||||
}
|
||||
|
||||
// pragma(extractelement) { funcdecl(s) }
|
||||
else if (ident == Id::Extractelement)
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
{
|
||||
error("takes no parameters");
|
||||
fatal();
|
||||
}
|
||||
return LLVMextractelement;
|
||||
}
|
||||
|
||||
// pragma(va_start) { templdecl(s) }
|
||||
else if (ident == Id::vastart)
|
||||
{
|
||||
@@ -375,6 +386,18 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||
}
|
||||
break;
|
||||
|
||||
case LLVMextractelement:
|
||||
if (FuncDeclaration* fd = s->isFuncDeclaration())
|
||||
{
|
||||
fd->llvmInternal = llvm_internal;
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma must only be used on function declarations.", ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
|
||||
case LLVMinline_asm:
|
||||
if (TemplateDeclaration* td = s->isTemplateDeclaration())
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ enum Pragma
|
||||
LLVMno_moduleinfo,
|
||||
LLVMalloca,
|
||||
LLVMshufflevector,
|
||||
LLVMextractelement,
|
||||
LLVMva_start,
|
||||
LLVMva_copy,
|
||||
LLVMva_end,
|
||||
|
||||
14
gen/toir.cpp
14
gen/toir.cpp
@@ -1007,7 +1007,19 @@ DValue* CallExp::toElem(IRState* p)
|
||||
LLValue* v1 = exp1->toElem(p)->getRVal();
|
||||
LLValue* v2 = exp2->toElem(p)->getRVal();
|
||||
return new DImValue(type, p->ir->CreateShuffleVector(v1, v2, maskVal));
|
||||
}
|
||||
}
|
||||
// extractelement
|
||||
else if(fndecl->llvmInternal == LLVMextractelement) {
|
||||
Expression* exp2 = static_cast<Expression*>(arguments->data[1]);
|
||||
if(exp2->op != TOKint64){
|
||||
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);
|
||||
Expression* exp1 = static_cast<Expression*>(arguments->data[0]);
|
||||
LLValue* vec = exp1->toElem(p)->getRVal();
|
||||
return new DImValue(type, p->ir->CreateExtractElement(vec, idx));
|
||||
}
|
||||
// fence instruction
|
||||
else if (fndecl->llvmInternal == LLVMfence) {
|
||||
if (arguments->dim != 1) {
|
||||
|
||||
Reference in New Issue
Block a user