aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
diff options
context:
space:
mode:
authorAlex Bradbury <asb@igalia.com>2022-07-06 13:56:10 +0100
committerAlex Bradbury <asb@igalia.com>2022-07-06 13:56:10 +0100
commit0a9eb870f5f85d7d07e020f9998f208cddecc89d (patch)
treed7b15c1a540610f35549901fbb22176966974690 /llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
parent5b3247bf9f715cc1b399af1e17540b3a3ce9cdec (diff)
downloadllvm-0a9eb870f5f85d7d07e020f9998f208cddecc89d.zip
llvm-0a9eb870f5f85d7d07e020f9998f208cddecc89d.tar.gz
llvm-0a9eb870f5f85d7d07e020f9998f208cddecc89d.tar.bz2
[WebAssembly][NFC] Reuse the regClassToValType helper in WebAssemblyMCInstLower
There's no need for WebAssemblyMCInstLower to carry its own functionally equivalent implementation.
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
index 2e6027a..e8b3542 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
@@ -154,25 +154,6 @@ MCOperand WebAssemblyMCInstLower::lowerTypeIndexOperand(
return MCOperand::createExpr(Expr);
}
-// Return the WebAssembly type associated with the given register class.
-static wasm::ValType getType(const TargetRegisterClass *RC) {
- if (RC == &WebAssembly::I32RegClass)
- return wasm::ValType::I32;
- if (RC == &WebAssembly::I64RegClass)
- return wasm::ValType::I64;
- if (RC == &WebAssembly::F32RegClass)
- return wasm::ValType::F32;
- if (RC == &WebAssembly::F64RegClass)
- return wasm::ValType::F64;
- if (RC == &WebAssembly::V128RegClass)
- return wasm::ValType::V128;
- if (RC == &WebAssembly::EXTERNREFRegClass)
- return wasm::ValType::EXTERNREF;
- if (RC == &WebAssembly::FUNCREFRegClass)
- return wasm::ValType::FUNCREF;
- llvm_unreachable("Unexpected register class");
-}
-
static void getFunctionReturns(const MachineInstr *MI,
SmallVectorImpl<wasm::ValType> &Returns) {
const Function &F = MI->getMF()->getFunction();
@@ -221,10 +202,12 @@ void WebAssemblyMCInstLower::lower(const MachineInstr *MI,
const MachineRegisterInfo &MRI =
MI->getParent()->getParent()->getRegInfo();
for (const MachineOperand &MO : MI->defs())
- Returns.push_back(getType(MRI.getRegClass(MO.getReg())));
+ Returns.push_back(
+ WebAssembly::regClassToValType(MRI.getRegClass(MO.getReg())));
for (const MachineOperand &MO : MI->explicit_uses())
if (MO.isReg())
- Params.push_back(getType(MRI.getRegClass(MO.getReg())));
+ Params.push_back(
+ WebAssembly::regClassToValType(MRI.getRegClass(MO.getReg())));
// call_indirect instructions have a callee operand at the end which
// doesn't count as a param.