|
14 | 14 | #include "BuiltinTargetFeatures.h" |
15 | 15 | #include "clang/Basic/IdentifierTable.h" |
16 | 16 | #include "clang/Basic/LangOptions.h" |
| 17 | +#include "clang/Basic/TargetBuiltins.h" |
17 | 18 | #include "clang/Basic/TargetInfo.h" |
18 | 19 | #include "llvm/ADT/StringRef.h" |
19 | 20 | using namespace clang; |
@@ -118,6 +119,18 @@ void Builtin::Context::InitializeTarget(const TargetInfo &Target, |
118 | 119 | for (const auto &Shard : AuxTargetShards) |
119 | 120 | NumAuxTargetBuiltins += Shard.Infos.size(); |
120 | 121 | } |
| 122 | + |
| 123 | + // FIXME: HACK FOR DEBUG |
| 124 | + if (Target.getTriple().isX86()) |
| 125 | + DebugHackTargetIsX86 = true; |
| 126 | + else if (Target.getTriple().isAArch64()) |
| 127 | + DebugHackTargetIsAArch64 = true; |
| 128 | + else if (Target.getTriple().isARM()) |
| 129 | + DebugHackTargetIsARM = true; |
| 130 | + else if (Target.getTriple().getArch() == llvm::Triple::hexagon) |
| 131 | + DebugHackTargetIsHexagon = true; |
| 132 | + else if (Target.getTriple().isNVPTX()) |
| 133 | + DebugHackTargetIsNVPTX = true; |
121 | 134 | } |
122 | 135 |
|
123 | 136 | bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) { |
@@ -214,6 +227,34 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table, |
214 | 227 | // Step #2: Register target-specific builtins. |
215 | 228 | for (const auto &Shard : TargetShards) |
216 | 229 | for (const auto &I : Shard.Infos) { |
| 230 | + // FIXME: Hacks for debugging |
| 231 | + if (DebugHackTargetIsX86 && ID == X86::BI__builtin_ia32_packsswb128) { |
| 232 | + if (I.getName(Shard) != "__builtin_ia32_packsswb128") |
| 233 | + llvm::report_fatal_error( |
| 234 | + llvm::Twine("Name for __builtin_ia32_packsswb128 is: '") + |
| 235 | + I.getName(Shard) + "'!!!"); |
| 236 | + } else if (DebugHackTargetIsAArch64 && |
| 237 | + ID == SVE::BI__builtin_sve_svundef_u8) { |
| 238 | + if (I.getName(Shard) != "__builtin_sve_svundef_u8") |
| 239 | + llvm::report_fatal_error( |
| 240 | + llvm::Twine("Name for __builtin_sve_svundef_u8 is: '") + |
| 241 | + I.getName(Shard) + "'!!!"); |
| 242 | + } else if (DebugHackTargetIsARM && ID == ARM::BI__ldrexd) { |
| 243 | + if (I.getName(Shard) != "__ldrexd") |
| 244 | + llvm::report_fatal_error(llvm::Twine("Name for __ldrexd is: '") + |
| 245 | + I.getName(Shard) + "'!!!"); |
| 246 | + } else if (DebugHackTargetIsHexagon && |
| 247 | + ID == Hexagon::BI__builtin_HEXAGON_V6_vsub_sf_bf) { |
| 248 | + if (I.getName(Shard) != "__builtin_HEXAGON_V6_vsub_sf_bf") |
| 249 | + llvm::report_fatal_error( |
| 250 | + llvm::Twine("Name for __builtin_HEXAGON_V6_vsub_sf_bf is: '") + |
| 251 | + I.getName(Shard) + "'!!!"); |
| 252 | + } else if (DebugHackTargetIsNVPTX && ID == NVPTX::BI__nvvm_vote_all) { |
| 253 | + if (I.getName(Shard) != "__nvvm_vote_all") |
| 254 | + llvm::report_fatal_error( |
| 255 | + llvm::Twine("Name for __nvvm_vote_all is: '") + |
| 256 | + I.getName(Shard) + "'!!!"); |
| 257 | + } |
217 | 258 | if (builtinIsSupported(*Shard.Strings, I, LangOpts)) |
218 | 259 | Table.get(I.getName(Shard)).setBuiltinID(ID); |
219 | 260 | ++ID; |
|
0 commit comments