Reverts wrong modification to MachineBlockPlacement & BranchFolding; uses a new strat...
[oota-llvm.git] / lib / CodeGen / FaultMaps.cpp
index 2f849511d69431cbb796400fb0e959209455ded3..2acafafdb9fcc141a36ff408cf048259dd7c9cf3 100644 (file)
@@ -25,7 +25,7 @@ const char *FaultMaps::WFMP = "Fault Maps: ";
 
 FaultMaps::FaultMaps(AsmPrinter &AP) : AP(AP) {}
 
-void FaultMaps::recordFaultingOp(FaultType FaultTy,
+void FaultMaps::recordFaultingOp(FaultKind FaultTy,
                                  const MCSymbol *HandlerLabel) {
   MCContext &OutContext = AP.OutStreamer->getContext();
   MCSymbol *FaultingLabel = OutContext.createTempSymbol();
@@ -89,8 +89,8 @@ void FaultMaps::emitFunctionInfo(const MCSymbol *FnLabel,
 
   for (auto &Fault : FFI) {
     DEBUG(dbgs() << WFMP << "    fault type: "
-          << faultTypeToString(Fault.FaultType) << "\n");
-    OS.EmitIntValue(Fault.FaultType, 4);
+          << faultTypeToString(Fault.Kind) << "\n");
+    OS.EmitIntValue(Fault.Kind, 4);
 
     DEBUG(dbgs() << WFMP << "    faulting PC offset: "
           << *Fault.FaultingOffsetExpr << "\n");
@@ -103,7 +103,7 @@ void FaultMaps::emitFunctionInfo(const MCSymbol *FnLabel,
 }
 
 
-const char *FaultMaps::faultTypeToString(FaultMaps::FaultType FT) {
+const char *FaultMaps::faultTypeToString(FaultMaps::FaultKind FT) {
   switch (FT) {
   default:
     llvm_unreachable("unhandled fault type!");
@@ -112,3 +112,39 @@ const char *FaultMaps::faultTypeToString(FaultMaps::FaultType FT) {
     return "FaultingLoad";
   }
 }
+
+raw_ostream &llvm::
+operator<<(raw_ostream &OS,
+           const FaultMapParser::FunctionFaultInfoAccessor &FFI) {
+  OS << "Fault kind: "
+     << FaultMaps::faultTypeToString((FaultMaps::FaultKind)FFI.getFaultKind())
+     << ", faulting PC offset: " << FFI.getFaultingPCOffset()
+     << ", handling PC offset: " << FFI.getHandlerPCOffset();
+  return OS;
+}
+
+raw_ostream &llvm::
+operator<<(raw_ostream &OS, const FaultMapParser::FunctionInfoAccessor &FI) {
+  OS << "FunctionAddress: " << format_hex(FI.getFunctionAddr(), 8)
+     << ", NumFaultingPCs: " << FI.getNumFaultingPCs() << "\n";
+  for (unsigned i = 0, e = FI.getNumFaultingPCs(); i != e; ++i)
+    OS << FI.getFunctionFaultInfoAt(i) << "\n";
+  return OS;
+}
+
+raw_ostream &llvm::operator<<(raw_ostream &OS, const FaultMapParser &FMP) {
+  OS << "Version: " << format_hex(FMP.getFaultMapVersion(), 2) << "\n";
+  OS << "NumFunctions: " << FMP.getNumFunctions() << "\n";
+
+  if (FMP.getNumFunctions() == 0)
+    return OS;
+
+  FaultMapParser::FunctionInfoAccessor FI;
+
+  for (unsigned i = 0, e = FMP.getNumFunctions(); i != e; ++i) {
+    FI = (i == 0) ? FMP.getFirstFunctionInfo() : FI.getNextFunctionInfo();
+    OS << FI;
+  }
+
+  return OS;
+}