TableGen: allow use of uint64_t for available features mask.
[oota-llvm.git] / lib / ExecutionEngine / RuntimeDyld / RuntimeDyldChecker.cpp
index 3ac4dd6b4f04f5c036e689cb4b03977206ed6b4a..d244f45b0803b767481b5d703acfca9aaa865ca0 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/MC/MCDisassembler.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/Support/StringRefMemoryObject.h"
+#include "llvm/Support/Path.h"
 #include "RuntimeDyldCheckerImpl.h"
 #include "RuntimeDyldImpl.h"
 #include <cctype>
@@ -61,8 +62,8 @@ public:
 
     if (LHSResult.getValue() != RHSResult.getValue()) {
       Checker.ErrStream << "Expression '" << Expr << "' is false: "
-                        << format("0x%lx", LHSResult.getValue())
-                        << " != " << format("0x%lx", RHSResult.getValue())
+                        << format("0x%" PRIx64, LHSResult.getValue())
+                        << " != " << format("0x%" PRIx64, RHSResult.getValue())
                         << "\n";
       return false;
     }
@@ -519,7 +520,7 @@ private:
       std::tie(SubExprResult, RemainingExpr) = evalParensExpr(Expr, PCtx);
     else if (Expr[0] == '*')
       std::tie(SubExprResult, RemainingExpr) = evalLoadExpr(Expr);
-    else if (isalpha(Expr[0]))
+    else if (isalpha(Expr[0]) || Expr[0] == '_')
       std::tie(SubExprResult, RemainingExpr) = evalIdentifierExpr(Expr, PCtx);
     else if (isdigit(Expr[0]))
       std::tie(SubExprResult, RemainingExpr) = evalNumberExpr(Expr);
@@ -713,8 +714,23 @@ std::pair<uint64_t, std::string> RuntimeDyldCheckerImpl::getStubAddrFor(
     bool IsInsideLoad) const {
 
   auto SI1 = Stubs.find(FileName);
-  if (SI1 == Stubs.end())
-    return std::make_pair(0, ("File '" + FileName + "' not found.\n").str());
+  if (SI1 == Stubs.end()) {
+    std::string ErrorMsg = "File '";
+    ErrorMsg += FileName;
+    ErrorMsg += "' not found. ";
+    if (Stubs.empty())
+      ErrorMsg += "No stubs registered.";
+    else {
+      ErrorMsg += "Available files are:";
+      for (const auto& StubEntry : Stubs) {
+        ErrorMsg += " '";
+        ErrorMsg += StubEntry.first;
+        ErrorMsg += "'";
+      }
+    }
+    ErrorMsg += "\n";
+    return std::make_pair(0, ErrorMsg);
+  }
 
   const SectionStubMap &SectionStubs = SI1->second;
   auto SI2 = SectionStubs.find(SectionName);
@@ -733,12 +749,12 @@ std::pair<uint64_t, std::string> RuntimeDyldCheckerImpl::getStubAddrFor(
 
   uint64_t Addr;
   if (IsInsideLoad) {
-    uint64_t SectionBase = getRTDyld().Sections[SectionID].LoadAddress;
-    Addr = SectionBase + StubOffset;
-  } else {
     uintptr_t SectionBase =
         reinterpret_cast<uintptr_t>(getRTDyld().Sections[SectionID].Address);
     Addr = static_cast<uint64_t>(SectionBase) + StubOffset;
+  } else {
+    uint64_t SectionBase = getRTDyld().Sections[SectionID].LoadAddress;
+    Addr = SectionBase + StubOffset;
   }
 
   return std::make_pair(Addr, std::string(""));
@@ -757,8 +773,9 @@ RuntimeDyldCheckerImpl::getSubsectionStartingAt(StringRef Name) const {
 }
 
 void RuntimeDyldCheckerImpl::registerStubMap(
-    StringRef FileName, unsigned SectionID,
+    StringRef FilePath, unsigned SectionID,
     const RuntimeDyldImpl::StubMap &RTDyldStubs) {
+  StringRef FileName = sys::path::filename(FilePath);
   const SectionEntry &Section = getRTDyld().Sections[SectionID];
   StringRef SectionName = Section.Name;
   for (auto &StubMapEntry : RTDyldStubs) {