diff --git a/dmd/idgen.c b/dmd/idgen.c index 2b50af7b..dad04726 100644 --- a/dmd/idgen.c +++ b/dmd/idgen.c @@ -223,7 +223,26 @@ Msgtable msgtable[] = { "msg" }, #if IN_LLVM - // LDC pragmas + // LDC-specific pragmas. + { "LDC_intrinsic" }, + { "LDC_no_typeinfo" }, + { "LDC_no_moduleinfo" }, + { "LDC_alloca" }, + { "LDC_va_start" }, + { "LDC_va_copy" }, + { "LDC_va_end" }, + { "LDC_va_arg" }, + { "LDC_verbose" }, + { "LDC_allow_inline" }, + { "LDC_inline_asm" }, + { "LDC_inline_ir" }, + { "LDC_fence" }, + { "LDC_atomic_load" }, + { "LDC_atomic_store" }, + { "LDC_atomic_cmp_xchg" }, + { "LDC_atomic_rmw" }, + + // Deprecated LDC pragmas lacking the vendor prefix. { "intrinsic" }, { "no_typeinfo" }, { "no_moduleinfo" }, diff --git a/dmd2/idgen.c b/dmd2/idgen.c index ae6d88e0..80ad00c1 100644 --- a/dmd2/idgen.c +++ b/dmd2/idgen.c @@ -267,7 +267,26 @@ Msgtable msgtable[] = { "startaddress" }, #if IN_LLVM - // LDC pragmas + // LDC-specific pragmas. + { "LDC_intrinsic" }, + { "LDC_no_typeinfo" }, + { "LDC_no_moduleinfo" }, + { "LDC_alloca" }, + { "LDC_va_start" }, + { "LDC_va_copy" }, + { "LDC_va_end" }, + { "LDC_va_arg" }, + { "LDC_verbose" }, + { "LDC_allow_inline" }, + { "LDC_inline_asm" }, + { "LDC_inline_ir" }, + { "LDC_fence" }, + { "LDC_atomic_load" }, + { "LDC_atomic_store" }, + { "LDC_atomic_cmp_xchg" }, + { "LDC_atomic_rmw" }, + + // Deprecated LDC pragmas lacking the vendor prefix. { "intrinsic" }, { "no_typeinfo" }, { "no_moduleinfo" }, diff --git a/gen/pragma.cpp b/gen/pragma.cpp index 13076a59..b14ccbd8 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -22,6 +22,27 @@ static bool parseStringExp(Expression* e, std::string& res) return false; } +static void pragmaDeprecated(Identifier* oldIdent, Identifier* newIdent) +{ +#ifndef DMDV1 + // Do not print a deprecation warning for D1 – we do not want to + // introduce needless breakage at this stage. + if (!global.params.useDeprecated) + error("non-vendor-prefixed pragma '%s' is deprecated; use '%s' instead"); +#endif +} + +static bool matchPragma(Identifier* needle, Identifier* ident, Identifier* oldIdent) +{ + if (needle == ident) return true; + if (needle == oldIdent) + { + pragmaDeprecated(oldIdent, ident); + return true; + } + return false; +} + Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) { Identifier *ident = decl->ident; @@ -29,7 +50,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) Expression *expr = (args && args->dim > 0) ? (*args)[0]->semantic(sc) : 0; // pragma(intrinsic, "string") { funcdecl(s) } - if (ident == Id::intrinsic) + if (matchPragma(ident, Id::LDC_intrinsic, Id::intrinsic)) { if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) { @@ -75,7 +96,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(notypeinfo) { typedecl(s) } - else if (ident == Id::no_typeinfo) + else if (matchPragma(ident, Id::LDC_no_typeinfo, Id::no_typeinfo)) { if (args && args->dim > 0) { @@ -86,7 +107,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(nomoduleinfo) ; - else if (ident == Id::no_moduleinfo) + else if (matchPragma(ident, Id::LDC_no_moduleinfo, Id::no_moduleinfo)) { if (args && args->dim > 0) { @@ -97,7 +118,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(alloca) { funcdecl(s) } - else if (ident == Id::Alloca) + else if (matchPragma(ident, Id::LDC_alloca, Id::Alloca)) { if (args && args->dim > 0) { @@ -108,7 +129,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(va_start) { templdecl(s) } - else if (ident == Id::vastart) + else if (matchPragma(ident, Id::LDC_va_start, Id::vastart)) { if (args && args->dim > 0) { @@ -119,7 +140,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(va_copy) { funcdecl(s) } - else if (ident == Id::vacopy) + else if (matchPragma(ident, Id::LDC_va_copy, Id::vacopy)) { if (args && args->dim > 0) { @@ -130,7 +151,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(va_end) { funcdecl(s) } - else if (ident == Id::vaend) + else if (matchPragma(ident, Id::LDC_va_end, Id::vaend)) { if (args && args->dim > 0) { @@ -141,7 +162,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(va_arg) { templdecl(s) } - else if (ident == Id::vaarg) + else if (matchPragma(ident, Id::LDC_va_arg, Id::vaarg)) { if (args && args->dim > 0) { @@ -152,7 +173,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(fence) { funcdecl(s) } - else if (ident == Id::fence) + else if (matchPragma(ident, Id::LDC_fence, Id::fence)) { if (args && args->dim > 0) { @@ -163,7 +184,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(atomic_load) { templdecl(s) } - else if (ident == Id::atomic_load) + else if (matchPragma(ident, Id::LDC_atomic_load, Id::atomic_load)) { if (args && args->dim > 0) { @@ -174,7 +195,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(atomic_store) { templdecl(s) } - else if (ident == Id::atomic_store) + else if (matchPragma(ident, Id::LDC_atomic_store, Id::atomic_store)) { if (args && args->dim > 0) { @@ -185,7 +206,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(atomic_cmp_xchg) { templdecl(s) } - else if (ident == Id::atomic_cmp_xchg) + else if (matchPragma(ident, Id::LDC_atomic_cmp_xchg, Id::atomic_cmp_xchg)) { if (args && args->dim > 0) { @@ -196,7 +217,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(atomic_rmw, "string") { templdecl(s) } - else if (ident == Id::atomic_rmw) + else if (matchPragma(ident, Id::LDC_atomic_rmw, Id::atomic_rmw)) { if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) { @@ -209,6 +230,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) // pragma(ldc, "string") { templdecl(s) } else if (ident == Id::ldc) { + pragmaDeprecated(Id::ldc, Id::LDC_verbose); Expression* expr; if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) { @@ -226,8 +248,19 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } } + // pragma(LDC_verbose); + else if (ident == Id::LDC_verbose) + { + if (args && args->dim > 0) + { + error("takes no parameters"); + fatal(); + } + sc->module->llvmForceLogging = true; + } + // pragma(llvm_inline_asm) { templdecl(s) } - else if (ident == Id::llvm_inline_asm) + else if (matchPragma(ident, Id::LDC_inline_asm, Id::llvm_inline_asm)) { if (args && args->dim > 0) { @@ -238,7 +271,7 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str) } // pragma(llvm_inline_ir) { templdecl(s) } - else if (ident == Id::llvm_inline_ir) + else if (matchPragma(ident, Id::LDC_inline_ir, Id::llvm_inline_ir)) { if (args && args->dim > 0) {