summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp32
-rw-r--r--llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h7
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp16
3 files changed, 24 insertions, 31 deletions
diff --git a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
index 9b94806c953..3a151dec16f 100644
--- a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
@@ -98,22 +98,7 @@ void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
case WebAssembly::PARAM:
case WebAssembly::RESULT:
case WebAssembly::LOCAL:
- switch (Op.getImm()) {
- case MVT::i32:
- O << "i32";
- break;
- case MVT::i64:
- O << "i64";
- break;
- case MVT::f32:
- O << "f32";
- break;
- case MVT::f64:
- O << "f64";
- break;
- default:
- llvm_unreachable("unexpected type");
- }
+ O << WebAssembly::TypeToString(MVT::SimpleValueType(Op.getImm()));
break;
default:
O << Op.getImm();
@@ -126,3 +111,18 @@ void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
Op.getExpr()->print(O, &MAI);
}
}
+
+const char *llvm::WebAssembly::TypeToString(MVT Ty) {
+ switch (Ty.SimpleTy) {
+ case MVT::i32:
+ return "i32";
+ case MVT::i64:
+ return "i64";
+ case MVT::f32:
+ return "f32";
+ case MVT::f64:
+ return "f64";
+ default:
+ llvm_unreachable("unsupported type");
+ }
+}
diff --git a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h
index 319c8ee1d5d..20569da0b11 100644
--- a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h
+++ b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h
@@ -17,6 +17,7 @@
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/CodeGen/MachineValueType.h"
namespace llvm {
@@ -40,6 +41,12 @@ public:
static const char *getRegisterName(unsigned RegNo);
};
+namespace WebAssembly {
+
+const char *TypeToString(MVT Ty);
+
+} // end namespace WebAssembly
+
} // end namespace llvm
#endif
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index cfabc21ea4d..1b175a7f8d5 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -115,21 +115,7 @@ std::string WebAssemblyAsmPrinter::regToString(const MachineOperand &MO) {
}
const char *WebAssemblyAsmPrinter::toString(MVT VT) const {
- switch (VT.SimpleTy) {
- default:
- break;
- case MVT::f32:
- return "f32";
- case MVT::f64:
- return "f64";
- case MVT::i32:
- return "i32";
- case MVT::i64:
- return "i64";
- }
- DEBUG(dbgs() << "Invalid type " << EVT(VT).getEVTString() << '\n');
- llvm_unreachable("invalid type");
- return "<invalid>";
+ return WebAssembly::TypeToString(VT);
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud