36 #include "tce_config.h"
41 #include <llvm/CodeGen/MachineInstr.h>
42 #include <llvm/CodeGen/MachineOperand.h>
43 #include <llvm/IR/DebugLoc.h>
44 #include <llvm/IR/DebugInfo.h>
53 std::tuple<std::string, size_t>
56 DebugLoc dl = mi.getDebugLoc();
57 if (!dl)
return std::make_tuple(
"", 0);
59 bool hasDebugInfo =
false;
60 hasDebugInfo = dl.getScope() != NULL;
61 if (!hasDebugInfo)
return std::make_tuple(
"", 0);
63 size_t sourceLineNumber = 0;
67 sourceLineNumber = dl.getLine();
69 cast<DIScope>(dl.getScope())->getFilename().str());
70 return std::make_tuple(sourceFileName, sourceLineNumber);
82 if (!srcFile.empty()) {
83 return srcFile +
":" + std::to_string(srcLine) +
": ";
96 unsigned asmOpdPos = 0;
97 unsigned endPos = mi.getNumOperands();
98 unsigned i = InlineAsm::MIOp_FirstOperand;
101 const MachineOperand& mo = mi.getOperand(i);
102 if (mo.isMetadata()) {
106 unsigned opdKind = InlineAsm::getKind(mo.getImm());
107 unsigned numAsmOpds = InlineAsm::getNumOperandRegisters(mo.getImm());
108 unsigned flagOpdBegin = i + 1;
109 unsigned flagOpdEnd = flagOpdBegin + numAsmOpds;
110 std::vector<const llvm::MachineOperand*> flagOps;
111 for (
unsigned opdIdx = flagOpdBegin; opdIdx < flagOpdEnd; opdIdx++) {
112 flagOps.push_back(&mi.getOperand(opdIdx));
114 result.insert({asmOpdPos, std::make_tuple(opdKind, flagOps)});