mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
add __traits(getTargetInfo, "dcomputeTargets") (#3090)
This commit is contained in:
parent
e11079513c
commit
b750ce0c27
5 changed files with 30 additions and 2 deletions
|
@ -2758,6 +2758,11 @@ extern (C++) final class TupleExp : Expression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TupleExp create(Loc loc, Expressions* exps)
|
||||||
|
{
|
||||||
|
return new TupleExp(loc, exps);
|
||||||
|
}
|
||||||
|
|
||||||
override TupleExp toTupleExp()
|
override TupleExp toTupleExp()
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -424,6 +424,7 @@ public:
|
||||||
*/
|
*/
|
||||||
Expressions *exps;
|
Expressions *exps;
|
||||||
|
|
||||||
|
static TupleExp *create(Loc loc, Expressions *exps);
|
||||||
TupleExp *toTupleExp();
|
TupleExp *toTupleExp();
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
bool equals(RootObject *o);
|
bool equals(RootObject *o);
|
||||||
|
|
|
@ -1073,9 +1073,9 @@ void codegenModules(Modules &modules) {
|
||||||
if (!computeModules.empty()) {
|
if (!computeModules.empty()) {
|
||||||
for (auto &mod : computeModules)
|
for (auto &mod : computeModules)
|
||||||
dccg.emit(mod);
|
dccg.emit(mod);
|
||||||
|
|
||||||
dccg.writeModules();
|
|
||||||
}
|
}
|
||||||
|
dccg.writeModules();
|
||||||
|
|
||||||
// We may have removed all object files, if so don't link.
|
// We may have removed all object files, if so don't link.
|
||||||
if (global.params.objfiles.dim == 0)
|
if (global.params.objfiles.dim == 0)
|
||||||
global.params.link = false;
|
global.params.link = false;
|
||||||
|
|
|
@ -269,5 +269,20 @@ Expression *Target::getTargetInfo(const char *name_, const Loc &loc) {
|
||||||
if (name == "cppStd")
|
if (name == "cppStd")
|
||||||
return createIntegerExp(static_cast<unsigned>(global.params.cplusplus));
|
return createIntegerExp(static_cast<unsigned>(global.params.cplusplus));
|
||||||
|
|
||||||
|
#if LDC_LLVM_SUPPORTED_TARGET_SPIRV || LDC_LLVM_SUPPORTED_TARGET_NVPTX
|
||||||
|
if (name == "dcomputeTargets") {
|
||||||
|
Expressions* exps = new Expressions();
|
||||||
|
for (auto &targ : opts::dcomputeTargets) {
|
||||||
|
exps->push(createStringExp(mem.xstrdup(targ.c_str())));
|
||||||
|
}
|
||||||
|
return TupleExp::create(loc, exps);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "dcomputeFilePrefix") {
|
||||||
|
return createStringExp(
|
||||||
|
mem.xstrdup(opts::dcomputeFilePrefix.c_str()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
7
tests/semantic/target_traits_dcompute.d
Normal file
7
tests/semantic/target_traits_dcompute.d
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// Tests LDC-specific target __traits
|
||||||
|
|
||||||
|
// RUN: %ldc -c %s -mdcompute-targets=cuda-350 -mdcompute-file-prefix=testing
|
||||||
|
// REQUIRES: target_NVPTX
|
||||||
|
|
||||||
|
static assert([ __traits(getTargetInfo, "dcomputeTargets") ] == ["cuda-350"]);
|
||||||
|
static assert(__traits(getTargetInfo, "dcomputeFilePrefix") == "testing");
|
Loading…
Add table
Add a link
Reference in a new issue