diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
commit | eb11fae6d08f479c0799db45860a98af528fa6e7 (patch) | |
tree | 44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp | |
parent | b8a2042aa938069e862750553db0e4d82d25822c (diff) |
Notes
Diffstat (limited to 'lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp')
-rw-r--r-- | lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp b/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp index c3f0f2787146..10fa798ac8d7 100644 --- a/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp +++ b/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// /// /// \file -/// \brief Print MCInst instructions to wasm format. +/// Print MCInst instructions to wasm format. /// //===----------------------------------------------------------------------===// @@ -46,7 +46,7 @@ void WebAssemblyInstPrinter::printRegName(raw_ostream &OS, void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot, - const MCSubtargetInfo & /*STI*/) { + const MCSubtargetInfo &STI) { // Print the instruction (this uses the AsmStrings from the .td files). printInstruction(MI, OS); @@ -82,10 +82,12 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, ControlFlowStack.push_back(std::make_pair(ControlFlowCounter++, false)); break; case WebAssembly::END_LOOP: - ControlFlowStack.pop_back(); + // Have to guard against an empty stack, in case of mismatched pairs + // in assembly parsing. + if (!ControlFlowStack.empty()) ControlFlowStack.pop_back(); break; case WebAssembly::END_BLOCK: - printAnnotation( + if (!ControlFlowStack.empty()) printAnnotation( OS, "label" + utostr(ControlFlowStack.pop_back_val().first) + ':'); break; } @@ -176,10 +178,10 @@ void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, if (Info.OperandType == WebAssembly::OPERAND_F32IMM) { // TODO: MC converts all floating point immediate operands to double. // This is fine for numeric values, but may cause NaNs to change bits. - O << toString(APFloat(float(Op.getFPImm()))); + O << ::toString(APFloat(float(Op.getFPImm()))); } else { assert(Info.OperandType == WebAssembly::OPERAND_F64IMM); - O << toString(APFloat(Op.getFPImm())); + O << ::toString(APFloat(Op.getFPImm())); } } else { assert((OpNo < MII.get(MI->getOpcode()).getNumOperands() || @@ -192,20 +194,16 @@ void WebAssemblyInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, } } -void -WebAssemblyInstPrinter::printWebAssemblyP2AlignOperand(const MCInst *MI, - unsigned OpNo, - raw_ostream &O) { +void WebAssemblyInstPrinter::printWebAssemblyP2AlignOperand( + const MCInst *MI, unsigned OpNo, raw_ostream &O) { int64_t Imm = MI->getOperand(OpNo).getImm(); if (Imm == WebAssembly::GetDefaultP2Align(MI->getOpcode())) return; O << ":p2align=" << Imm; } -void -WebAssemblyInstPrinter::printWebAssemblySignatureOperand(const MCInst *MI, - unsigned OpNo, - raw_ostream &O) { +void WebAssemblyInstPrinter::printWebAssemblySignatureOperand( + const MCInst *MI, unsigned OpNo, raw_ostream &O) { int64_t Imm = MI->getOperand(OpNo).getImm(); switch (WebAssembly::ExprType(Imm)) { case WebAssembly::ExprType::Void: break; @@ -220,6 +218,7 @@ WebAssemblyInstPrinter::printWebAssemblySignatureOperand(const MCInst *MI, case WebAssembly::ExprType::B8x16: O << "b8x16"; break; case WebAssembly::ExprType::B16x8: O << "b16x8"; break; case WebAssembly::ExprType::B32x4: O << "b32x4"; break; + case WebAssembly::ExprType::ExceptRef: O << "except_ref"; break; } } @@ -238,6 +237,8 @@ const char *llvm::WebAssembly::TypeToString(MVT Ty) { case MVT::v4i32: case MVT::v4f32: return "v128"; + case MVT::ExceptRef: + return "except_ref"; default: llvm_unreachable("unsupported type"); } @@ -253,6 +254,8 @@ const char *llvm::WebAssembly::TypeToString(wasm::ValType Type) { return "f32"; case wasm::ValType::F64: return "f64"; + case wasm::ValType::EXCEPT_REF: + return "except_ref"; } llvm_unreachable("unsupported type"); } |