[PATCH] D158370: [llvm][NFC] Refactor AutoUpgrade case 'w'
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 20 10:10:28 PDT 2023
urnathan created this revision.
urnathan added reviewers: nikic, arsenm.
Herald added subscribers: StephenFan, sunfish, hiraditya.
Herald added a project: All.
urnathan requested review of this revision.
Herald added subscribers: llvm-commits, aheejin, wdng.
Herald added a project: LLVM.
Here's the refactoring of `case 'w':`. Primarily check a 'wasm' prefix before proceeding, and a bit of common handling for some of the intrinsics therein.
https://reviews.llvm.org/D158370
Files:
llvm/lib/IR/AutoUpgrade.cpp
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -1188,36 +1188,34 @@
}
case 'w':
- if (Name.startswith("wasm.fma.")) {
- rename(F);
- NewFn = Intrinsic::getDeclaration(
- F->getParent(), Intrinsic::wasm_relaxed_madd, F->getReturnType());
- return true;
- }
- if (Name.startswith("wasm.fms.")) {
- rename(F);
- NewFn = Intrinsic::getDeclaration(
- F->getParent(), Intrinsic::wasm_relaxed_nmadd, F->getReturnType());
- return true;
- }
- if (Name.startswith("wasm.laneselect.")) {
- rename(F);
- NewFn = Intrinsic::getDeclaration(
- F->getParent(), Intrinsic::wasm_relaxed_laneselect,
- F->getReturnType());
- return true;
- }
- if (Name == "wasm.dot.i8x16.i7x16.signed") {
- rename(F);
- NewFn = Intrinsic::getDeclaration(
- F->getParent(), Intrinsic::wasm_relaxed_dot_i8x16_i7x16_signed);
- return true;
- }
- if (Name == "wasm.dot.i8x16.i7x16.add.signed") {
- rename(F);
- NewFn = Intrinsic::getDeclaration(
- F->getParent(), Intrinsic::wasm_relaxed_dot_i8x16_i7x16_add_signed);
- return true;
+ if (Name.consume_front("wasm.")) {
+ Intrinsic::ID ID =
+ StringSwitch<Intrinsic::ID>(Name)
+ .StartsWith("fma.", Intrinsic::wasm_relaxed_madd)
+ .StartsWith("fms.", Intrinsic::wasm_relaxed_nmadd)
+ .StartsWith("laneselect.", Intrinsic::wasm_relaxed_laneselect)
+ .Default(Intrinsic::not_intrinsic);
+ if (ID != Intrinsic::not_intrinsic) {
+ rename(F);
+ NewFn =
+ Intrinsic::getDeclaration(F->getParent(), ID, F->getReturnType());
+ return true;
+ }
+
+ if (Name.consume_front("dot.i8x16.i7x16.")) {
+ ID = StringSwitch<Intrinsic::ID>(Name)
+ .Case("signed", Intrinsic::wasm_relaxed_dot_i8x16_i7x16_signed)
+ .Case("add.signed",
+ Intrinsic::wasm_relaxed_dot_i8x16_i7x16_add_signed)
+ .Default(Intrinsic::not_intrinsic);
+ if (ID != Intrinsic::not_intrinsic) {
+ rename(F);
+ NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
+ return true;
+ }
+ break; // No other 'wasm.dot.i8x16.i7x16.*'
+ }
+ break; // No other 'wasm.*'
}
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158370.551853.patch
Type: text/x-patch
Size: 2486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230820/25fb8790/attachment.bin>
More information about the llvm-commits
mailing list