summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/InstPrinter
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2015-11-23 16:50:18 +0000
committerDan Gohman <dan433584@gmail.com>2015-11-23 16:50:18 +0000
commit53828fd77797c8a9920619e19b5f4ad5cc779946 (patch)
tree4061406a202c67971f0cd133009ca96034b14921 /llvm/lib/Target/WebAssembly/InstPrinter
parent1ca881c4bbbe32213e435c050255b02764ea2004 (diff)
downloadbcm5719-llvm-53828fd77797c8a9920619e19b5f4ad5cc779946.tar.gz
bcm5719-llvm-53828fd77797c8a9920619e19b5f4ad5cc779946.zip
[WebAssembly] Emit .param, .result, and .local through MC.
This eliminates one of the main remaining uses of EmitRawText. llvm-svn: 253878
Diffstat (limited to 'llvm/lib/Target/WebAssembly/InstPrinter')
-rw-r--r--llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
index aed722cf739..a53a7cd2ed6 100644
--- a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
@@ -15,6 +15,7 @@
#include "InstPrinter/WebAssemblyInstPrinter.h"
#include "WebAssembly.h"
#include "WebAssemblyMachineFunctionInfo.h"
+#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
@@ -51,7 +52,8 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
if (Desc.isVariadic())
for (unsigned i = Desc.getNumOperands(), e = MI->getNumOperands(); i < e;
++i) {
- OS << ", ";
+ if (i != 0)
+ OS << ", ";
printOperand(MI, i, OS);
}
@@ -88,9 +90,24 @@ void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
O << "$push" << (WAReg & INT32_MAX);
else
O << "$discard";
- } else if (Op.isImm())
- O << Op.getImm();
- else if (Op.isFPImm())
+ } else if (Op.isImm()) {
+ switch (MI->getOpcode()) {
+ 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");
+ }
+ break;
+ default:
+ O << Op.getImm();
+ break;
+ }
+ } else if (Op.isFPImm())
O << toString(APFloat(Op.getFPImm()));
else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
OpenPOWER on IntegriCloud