mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
Make GCC intrinsics usable with @nogc and const *
Modifies gen_gccbuiltins.cpp to add the relatively new @nogc to each compiler intrinsic. Also adds 'const' to void* arguments of intrinsics with "IntrRead*Mem" set.
This commit is contained in:
parent
ab2e8e3646
commit
ca8019dcc6
1 changed files with 19 additions and 8 deletions
|
@ -32,7 +32,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
string dtype(Record* rec)
|
string dtype(Record* rec, bool readOnlyMem)
|
||||||
{
|
{
|
||||||
Init* typeInit = rec->getValueInit("VT");
|
Init* typeInit = rec->getValueInit("VT");
|
||||||
if(!typeInit)
|
if(!typeInit)
|
||||||
|
@ -41,7 +41,7 @@ string dtype(Record* rec)
|
||||||
string type = typeInit->getAsString();
|
string type = typeInit->getAsString();
|
||||||
|
|
||||||
if(type == "iPTR")
|
if(type == "iPTR")
|
||||||
return "void*";
|
return readOnlyMem ? "const void*" : "void*";
|
||||||
|
|
||||||
string vec = "";
|
string vec = "";
|
||||||
|
|
||||||
|
@ -94,9 +94,9 @@ string attributes(ListInit* propertyList)
|
||||||
? propertyList->getElementAsRecord(0)->getName() : "";
|
? propertyList->getElementAsRecord(0)->getName() : "";
|
||||||
|
|
||||||
return
|
return
|
||||||
prop == "IntrNoMem" ? "nothrow pure @safe" :
|
prop == "IntrNoMem" ? " pure @safe" :
|
||||||
prop == "IntrReadArgMem" ? "nothrow pure" :
|
prop == "IntrReadArgMem" ? " pure" :
|
||||||
prop == "IntrReadWriteArgMem" ? "nothrow pure" : "nothrow";
|
prop == "IntrReadWriteArgMem" ? " pure" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void processRecord(raw_ostream& os, Record& rec, string arch)
|
void processRecord(raw_ostream& os, Record& rec, string arch)
|
||||||
|
@ -114,6 +114,17 @@ void processRecord(raw_ostream& os, Record& rec, string arch)
|
||||||
replace(name.begin(), name.end(), '_', '.');
|
replace(name.begin(), name.end(), '_', '.');
|
||||||
name = string("llvm.") + name;
|
name = string("llvm.") + name;
|
||||||
|
|
||||||
|
ListInit* propsList = rec.getValueAsListInit("Properties");
|
||||||
|
string prop =
|
||||||
|
#if LDC_LLVM_VER >= 307
|
||||||
|
propsList->size()
|
||||||
|
#else
|
||||||
|
propsList->getSize()
|
||||||
|
#endif
|
||||||
|
? propsList->getElementAsRecord(0)->getName() : "";
|
||||||
|
|
||||||
|
bool readOnlyMem = prop == "IntrReadArgMem" || prop == "IntrReadMem";
|
||||||
|
|
||||||
ListInit* paramsList = rec.getValueAsListInit("ParamTypes");
|
ListInit* paramsList = rec.getValueAsListInit("ParamTypes");
|
||||||
vector<string> params;
|
vector<string> params;
|
||||||
for(unsigned int i = 0; i <
|
for(unsigned int i = 0; i <
|
||||||
|
@ -124,7 +135,7 @@ void processRecord(raw_ostream& os, Record& rec, string arch)
|
||||||
#endif
|
#endif
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
string t = dtype(paramsList->getElementAsRecord(i));
|
string t = dtype(paramsList->getElementAsRecord(i), readOnlyMem);
|
||||||
if(t == "")
|
if(t == "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -142,7 +153,7 @@ void processRecord(raw_ostream& os, Record& rec, string arch)
|
||||||
ret = "void";
|
ret = "void";
|
||||||
else if(sz == 1)
|
else if(sz == 1)
|
||||||
{
|
{
|
||||||
ret = dtype(retList->getElementAsRecord(0));
|
ret = dtype(retList->getElementAsRecord(0), false);
|
||||||
if(ret == "")
|
if(ret == "")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +178,7 @@ bool emit(raw_ostream& os, RecordKeeper& records)
|
||||||
{
|
{
|
||||||
os << "module ldc.gccbuiltins_";
|
os << "module ldc.gccbuiltins_";
|
||||||
os << arch;
|
os << arch;
|
||||||
os << "; \n\nimport core.simd;\n\n";
|
os << "; \n\nimport core.simd;\n\nnothrow @nogc:\n\n";
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 306
|
#if LDC_LLVM_VER >= 306
|
||||||
const auto &defs = records.getDefs();
|
const auto &defs = records.getDefs();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue