llvm.org GIT mirror llvm / 376a8a7
Print out the location of expanded multiclass defs in TableGen errors. When reporting an error for a defm, we would previously only report the location of the outer defm, which is not always where the error is. Now we also print the location of the expanded multiclass defs: lib/Target/X86/X86InstrSSE.td:2902:12: error: foo defm ADD : basic_sse12_fp_binop_s<0x58, "add", fadd, SSE_ALU_ITINS_S>, ^ lib/Target/X86/X86InstrSSE.td:2801:11: note: instantiated from multiclass defm PD : sse12_fp_packed<opc, !strconcat(OpcodeStr, "pd"), OpNode, VR128, ^ lib/Target/X86/X86InstrSSE.td:194:5: note: instantiated from multiclass def rm : PI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, x86memop:$src2), ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162409 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 8 years ago
8 changed file(s) with 41 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
1919 namespace llvm {
2020
2121 class TGError {
22 SMLoc Loc;
22 SmallVector Locs;
2323 std::string Message;
2424 public:
25 TGError(SMLoc loc, const std::string &message) : Loc(loc), Message(message) {}
25 TGError(ArrayRef locs, const std::string &message)
26 : Locs(locs.begin(), locs.end()), Message(message) {}
2627
27 SMLoc getLoc() const { return Loc; }
28 ArrayRef getLoc() const { return Locs; }
2829 const std::string &getMessage() const { return Message; }
2930 };
3031
31 void PrintWarning(SMLoc WarningLoc, const Twine &Msg);
32 void PrintWarning(ArrayRef WarningLoc, const Twine &Msg);
3233 void PrintWarning(const char *Loc, const Twine &Msg);
3334 void PrintWarning(const Twine &Msg);
3435 void PrintWarning(const TGError &Warning);
3536
36 void PrintError(SMLoc ErrorLoc, const Twine &Msg);
37 void PrintError(ArrayRef ErrorLoc, const Twine &Msg);
3738 void PrintError(const char *Loc, const Twine &Msg);
3839 void PrintError(const Twine &Msg);
3940 void PrintError(const TGError &Error);
13001300 // Unique record ID.
13011301 unsigned ID;
13021302 Init *Name;
1303 SMLoc Loc;
1303 // Location where record was instantiated, followed by the location of
1304 // multiclass prototypes used.
1305 SmallVector Locs;
13041306 std::vector TemplateArgs;
13051307 std::vector Values;
13061308 std::vector SuperClasses;
13161318 public:
13171319
13181320 // Constructs a record.
1319 explicit Record(const std::string &N, SMLoc loc, RecordKeeper &records) :
1320 ID(LastID++), Name(StringInit::get(N)), Loc(loc), TrackedRecords(records),
1321 TheInit(0) {
1321 explicit Record(const std::string &N, ArrayRef locs,
1322 RecordKeeper &records) :
1323 ID(LastID++), Name(StringInit::get(N)), Locs(locs.begin(), locs.end()),
1324 TrackedRecords(records), TheInit(0) {
13221325 init();
13231326 }
1324 explicit Record(Init *N, SMLoc loc, RecordKeeper &records) :
1325 ID(LastID++), Name(N), Loc(loc), TrackedRecords(records), TheInit(0) {
1327 explicit Record(Init *N, ArrayRef locs, RecordKeeper &records) :
1328 ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
1329 TrackedRecords(records), TheInit(0) {
13261330 init();
13271331 }
13281332 ~Record() {}
13441348 void setName(Init *Name); // Also updates RecordKeeper.
13451349 void setName(const std::string &Name); // Also updates RecordKeeper.
13461350
1347 SMLoc getLoc() const { return Loc; }
1351 ArrayRef getLoc() const { return Locs; }
13481352
13491353 /// get the corresponding DefInit.
13501354 DefInit *getDefInit();
1919
2020 SourceMgr SrcMgr;
2121
22 void PrintWarning(SMLoc WarningLoc, const Twine &Msg) {
23 SrcMgr.PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
22 static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind,
23 const Twine &Msg) {
24 SMLoc NullLoc;
25 if (Loc.empty())
26 Loc = NullLoc;
27 SrcMgr.PrintMessage(Loc.front(), Kind, Msg);
28 for (unsigned i = 1; i < Loc.size(); ++i)
29 SrcMgr.PrintMessage(Loc[i], SourceMgr::DK_Note,
30 "instantiated from multiclass");
31 }
32
33 void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) {
34 PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
2435 }
2536
2637 void PrintWarning(const char *Loc, const Twine &Msg) {
3546 PrintWarning(Warning.getLoc(), Warning.getMessage());
3647 }
3748
38 void PrintError(SMLoc ErrorLoc, const Twine &Msg) {
39 SrcMgr.PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
49 void PrintError(ArrayRef ErrorLoc, const Twine &Msg) {
50 PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
4051 }
4152
4253 void PrintError(const char *Loc, const Twine &Msg) {
22762276 DefName, StringRecTy::get())->Fold(DefProto, &MC);
22772277 }
22782278
2279 Record *CurRec = new Record(DefName, DefmPrefixLoc, Records);
2279 // Make a trail of SMLocs from the multiclass instantiations.
2280 SmallVector Locs(1, DefmPrefixLoc);
2281 Locs.append(DefProto->getLoc().begin(), DefProto->getLoc().end());
2282 Record *CurRec = new Record(DefName, Locs, Records);
22802283
22812284 SubClassReference Ref;
22822285 Ref.RefLoc = DefmPrefixLoc;
665665 }
666666
667667 static std::pair
668 parseTwoOperandConstraint(StringRef S, SMLoc Loc) {
668 parseTwoOperandConstraint(StringRef S, ArrayRef Loc) {
669669 // Split via the '='.
670670 std::pair Ops = S.split('=');
671671 if (Ops.second == "")
408408 /// successful match, with ResOp set to the result operand to be used.
409409 bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
410410 Record *InstOpRec, bool hasSubOps,
411 SMLoc Loc, CodeGenTarget &T,
411 ArrayRef Loc, CodeGenTarget &T,
412412 ResultOperand &ResOp) {
413413 Init *Arg = Result->getArg(AliasOpNo);
414414 DefInit *ADI = dynamic_cast(Arg);
318318 CodeGenInstAlias(Record *R, CodeGenTarget &T);
319319
320320 bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
321 Record *InstOpRec, bool hasSubOps, SMLoc Loc,
321 Record *InstOpRec, bool hasSubOps, ArrayRef Loc,
322322 CodeGenTarget &T, ResultOperand &ResOp);
323323 };
324324 }
297297 for (SubRegMap::const_iterator SI = SubRegs.begin(), SE = SubRegs.end();
298298 SI != SE; ++SI) {
299299 if (SI->second == this) {
300 SMLoc Loc;
300 ArrayRef Loc;
301301 if (TheDef)
302302 Loc = TheDef->getLoc();
303303 throw TGError(Loc, "Register " + getName() +
309309 if (Ins->second == SI->first)
310310 continue;
311311 // Trouble: Two different names for SI->second.
312 SMLoc Loc;
312 ArrayRef Loc;
313313 if (TheDef)
314314 Loc = TheDef->getLoc();
315315 throw TGError(Loc, "Sub-register can't have two names: " +