Skip to content

Commit a83165a

Browse files
committed
DO NOT MERGE: debug hacks for builtins
format hacks
1 parent 76dee9d commit a83165a

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

clang/include/clang/Basic/Builtins.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ class Context {
233233
unsigned NumTargetBuiltins = 0;
234234
unsigned NumAuxTargetBuiltins = 0;
235235

236+
// FIXME: HACK FOR DEBUG
237+
bool DebugHackTargetIsAArch64 = false;
238+
bool DebugHackTargetIsARM = false;
239+
bool DebugHackTargetIsHexagon = false;
240+
bool DebugHackTargetIsX86 = false;
241+
bool DebugHackTargetIsNVPTX = false;
242+
236243
public:
237244
Context();
238245

clang/lib/Basic/Builtins.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "BuiltinTargetFeatures.h"
1515
#include "clang/Basic/IdentifierTable.h"
1616
#include "clang/Basic/LangOptions.h"
17+
#include "clang/Basic/TargetBuiltins.h"
1718
#include "clang/Basic/TargetInfo.h"
1819
#include "llvm/ADT/StringRef.h"
1920
using namespace clang;
@@ -118,6 +119,18 @@ void Builtin::Context::InitializeTarget(const TargetInfo &Target,
118119
for (const auto &Shard : AuxTargetShards)
119120
NumAuxTargetBuiltins += Shard.Infos.size();
120121
}
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;
121134
}
122135

123136
bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) {
@@ -214,6 +227,34 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
214227
// Step #2: Register target-specific builtins.
215228
for (const auto &Shard : TargetShards)
216229
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+
}
217258
if (builtinIsSupported(*Shard.Strings, I, LangOpts))
218259
Table.get(I.getName(Shard)).setBuiltinID(ID);
219260
++ID;

0 commit comments

Comments
 (0)