-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Exegesis][RISCV] Add initial RVV support #128767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a0651b5
[Exegesis][RISCV] Add RVV support
mshockwave 0c4d943
fixup! Change the test check prefix
mshockwave bd1b6f8
Address review comments
mshockwave 32cb8fe
fixup! Address review comments
mshockwave f5bfd3f
Address minor review comments
mshockwave 2147220
Address more review comments
mshockwave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
llvm/test/tools/llvm-exegesis/RISCV/rvv/eligible-inst.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency \ | ||
| # RUN: --opcode-name=PseudoVCOMPRESS_VM_M2_E8,PseudoVCPOP_M_B32 | FileCheck %s --allow-empty --check-prefix=LATENCY | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVCOMPRESS_VM_M2_E8,PseudoVCPOP_M_B32 --min-instructions=100 | FileCheck %s --check-prefix=RTHROUGHPUT | ||
|
|
||
| # LATENCY-NOT: PseudoVCOMPRESS_VM_M2_E8 | ||
| # LATENCY-NOT: PseudoVCPOP_M_B32 | ||
|
|
||
| # RTHROUGHPUT: PseudoVCOMPRESS_VM_M2_E8 | ||
| # RTHROUGHPUT: PseudoVCPOP_M_B32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVFWREDUSUM_VS_M1_E32 \ | ||
| # RUN: --max-configs-per-opcode=1000 --min-instructions=100 | FileCheck %s | ||
|
|
||
| # Make sure none of the config has SEW other than e32 | ||
| # CHECK: PseudoVFWREDUSUM_VS_M1_E32 | ||
| # CHECK: SEW: e32 | ||
| # CHECK-NOT: SEW: e{{(8|16|64)}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=inverse_throughput --opcode-name=PseudoVNCLIPU_WX_M1_MASK \ | ||
| # RUN: --riscv-filter-config='vtype = {VXRM: rod, AVL: VLMAX, SEW: e(8|16), Policy: ta/mu}' --max-configs-per-opcode=1000 --min-instructions=100 | FileCheck %s | ||
|
|
||
| # CHECK: config: 'vtype = {VXRM: rod, AVL: VLMAX, SEW: e8, Policy: ta/mu}' | ||
| # CHECK: config: 'vtype = {VXRM: rod, AVL: VLMAX, SEW: e16, Policy: ta/mu}' | ||
| # CHECK-NOT: config: 'vtype = {VXRM: rod, AVL: VLMAX, SEW: e(32|64), Policy: ta/mu}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVWREDSUMU_VS_M8_E32 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s | ||
|
|
||
| # Make sure reduction ops don't have alias between vd and vs1 | ||
| # CHECK: instructions: | ||
| # CHECK-NEXT: PseudoVWREDSUMU_VS_M8_E32 | ||
| # CHECK-NOT: V[[REG:[0-9]+]] V[[REG]] V{{[0-9]+}}M8 V[[REG]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVXOR_VX_M4 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s | ||
|
|
||
| # Make sure all def / use operands are the same in latency mode. | ||
| # CHECK: instructions: | ||
| # CHECK-NEXT: PseudoVXOR_VX_M4 V[[REG:[0-9]+]]M4 V[[REG]]M4 V[[REG]]M4 X{{.*}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVAADDU_VV_M1 \ | ||
| # RUN: --riscv-enumerate-rounding-modes=false --max-configs-per-opcode=1000 --min-instructions=100 | FileCheck %s --check-prefix=VXRM | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVFADD_VFPR16_M1_E16 \ | ||
| # RUN: --riscv-enumerate-rounding-modes=false --max-configs-per-opcode=1000 --min-instructions=100 | FileCheck %s --check-prefix=FRM | ||
|
|
||
| # VXRM: PseudoVAADDU_VV_M1 | ||
| # VXRM: VXRM: rnu | ||
| # VXRM-NOT: VXRM: {{(rne|rdn|rod)}} | ||
|
|
||
| # FRM: PseudoVFADD_VFPR16_M1_E16 | ||
| # FRM: FRM: rne | ||
| # FRM-NOT: FRM: {{(rtz|rdn|rup|rmm|dyn)}} | ||
33 changes: 33 additions & 0 deletions
33
llvm/test/tools/llvm-exegesis/RISCV/rvv/valid-sew-zvk.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVAESDF_VS_M1_M1 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=ZVK | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVGHSH_VV_M1 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=ZVK | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVSM4K_VI_M1 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=ZVK | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVSM3C_VI_M2 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=ZVK | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVSHA2MS_VV_M1_E32 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --allow-empty --check-prefix=ZVKNH | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVSHA2MS_VV_M2_E64 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --allow-empty --check-prefix=ZVKNH | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p670 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVSM3C_VI_M1 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --allow-empty --check-prefix=EMPTY | ||
|
|
||
| # Most vector crypto only supports SEW=32, except Zvknhb which also supports SEW=64 | ||
| # ZVK-NOT: SEW: e{{(8|16)}} | ||
| # ZVK: SEW: e32 | ||
| # ZVK-NOT: SEW: e64 | ||
|
|
||
| # ZVKNH(A|B) can either have SEW=32 (EGW=128) or SEW=64 (EGW=256) | ||
|
|
||
| # ZVKNH-NOT: SEW: e{{(8|16)}} | ||
| # ZVKNH: SEW: e{{(32|64)}} | ||
|
|
||
| # EMPTY-NOT: SEW: e{{(8|16|32|64)}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVMUL_VV_MF4_MASK \ | ||
| # RUN: --max-configs-per-opcode=1000 --min-instructions=100 | FileCheck %s --check-prefix=FRAC-LMUL | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency \ | ||
| # RUN: --opcode-name=PseudoVFADD_VFPR16_M1_E16,PseudoVFADD_VV_M2_E16,PseudoVFCLASS_V_MF2 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=FP | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=inverse_throughput \ | ||
| # RUN: --opcode-name=PseudoVSEXT_VF8_M2,PseudoVZEXT_VF8_M2 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=VEXT | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-p470 -benchmark-phase=assemble-measured-code --mode=latency \ | ||
| # RUN: --opcode-name=PseudoVFREDUSUM_VS_M1_E16 --max-configs-per-opcode=1000 --min-instructions=100 | \ | ||
| # RUN: FileCheck %s --check-prefix=VFRED --allow-empty | ||
|
|
||
| # Make sure only the supported SEWs are generated for fractional LMUL. | ||
| # FRAC-LMUL: PseudoVMUL_VV_MF4_MASK | ||
| # FRAC-LMUL: SEW: e8 | ||
| # FRAC-LMUL: SEW: e16 | ||
| # FRAC-LMUL-NOT: SEW: e{{(32|64)}} | ||
|
|
||
| # Make sure only SEWs that are equal to the supported FLEN are generated | ||
| # FP: PseudoVFADD_VFPR16_M1_E16 | ||
| # FP-NOT: SEW: e8 | ||
| # FP: PseudoVFADD_VV_M2_E16 | ||
| # FP-NOT: SEW: e8 | ||
| # FP: PseudoVFCLASS_V_MF2 | ||
| # FP-NOT: SEW: e8 | ||
|
|
||
| # VS/ZEXT can only operate on SEW that will not lead to invalid EEW on the | ||
| # source operand. | ||
| # VEXT: PseudoVSEXT_VF8_M2 | ||
| # VEXT-NOT: SEW: e8 | ||
| # VEXT-NOT: SEW: e16 | ||
| # VEXT-NOT: SEW: e32 | ||
| # VEXT: SEW: e64 | ||
| # VEXT: PseudoVZEXT_VF8_M2 | ||
| # VEXT-NOT: SEW: e8 | ||
| # VEXT-NOT: SEW: e16 | ||
| # VEXT-NOT: SEW: e32 | ||
| # VEXT: SEW: e64 | ||
|
|
||
| # P470 doesn't have Zvfh so 16-bit vfredusum shouldn't exist | ||
| # VFRED-NOT: PseudoVFREDUSUM_VS_M1_E16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVFWREDUSUM_VS_M1_E32 \ | ||
| # RUN: --riscv-vlmax-for-vl --max-configs-per-opcode=1000 --min-instructions=100 | FileCheck %s | ||
|
|
||
| # Only allow VLMAX for AVL when -riscv-vlmax-for-vl is present | ||
| # CHECK: PseudoVFWREDUSUM_VS_M1_E32 | ||
| # CHECK: AVL: VLMAX | ||
| # CHECK-NOT: AVL: {{(simm5|<MCOperand: .*>)}} |
13 changes: 13 additions & 0 deletions
13
llvm/test/tools/llvm-exegesis/RISCV/rvv/vtype-rm-setup.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVFWREDUSUM_VS_M1_E32 \ | ||
| # RUN: --max-configs-per-opcode=1 --min-instructions=100 --dump-object-to-disk=%t.o > %t.txt | ||
| # RUN: llvm-objdump --triple=riscv64 -d %t.o | FileCheck %s --check-prefix=VFWREDUSUM | ||
| # RUN: llvm-exegesis -mtriple=riscv64 -mcpu=sifive-x280 -benchmark-phase=assemble-measured-code --mode=latency --opcode-name=PseudoVSSRL_VX_MF4 \ | ||
| # RUN: --max-configs-per-opcode=1 --min-instructions=100 --dump-object-to-disk=%t.o > %t.txt | ||
| # RUN: llvm-objdump --triple=riscv64 -d %t.o | FileCheck %s --check-prefix=VSSRL | ||
|
|
||
| # Make sure the correct VSETVL / VXRM write / FRM write instructions are generated | ||
| # VFWREDUSUM: vsetvli {{.*}}, zero, e32, m1, tu, ma | ||
| # VFWREDUSUM: fsrmi {{.*}}, 0x0 | ||
|
|
||
| # VSSRL: vsetvli {{.*}}, zero, e8, mf4, tu, ma | ||
| # VSSRL: csrwi vxrm, 0x0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //===- RISCVExegesisPasses.h - RISC-V specific Exegesis Passes --*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_TOOLS_EXEGESIS_LIB_RISCV_RISCVEXEGESISPASSES_H | ||
| #define LLVM_TOOLS_EXEGESIS_LIB_RISCV_RISCVEXEGESISPASSES_H | ||
| namespace llvm { | ||
| class FunctionPass; | ||
|
|
||
| namespace exegesis { | ||
| FunctionPass *createRISCVPreprocessingPass(); | ||
| FunctionPass *createRISCVPostprocessingPass(); | ||
| } // namespace exegesis | ||
| } // namespace llvm | ||
| #endif |
130 changes: 130 additions & 0 deletions
130
llvm/tools/llvm-exegesis/lib/RISCV/RISCVExegesisPostprocessing.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| //===- RISCVExegesisPostprocessing.cpp - Post processing MI for exegesis---===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // \file | ||
| // Currently there is only one post-processing we need to do for exegesis: | ||
| // Assign a physical register to VSETVL's rd if it's not X0 (i.e. VLMAX). | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "RISCV.h" | ||
| #include "RISCVExegesisPasses.h" | ||
| #include "llvm/CodeGen/MachineFunctionPass.h" | ||
| #include "llvm/CodeGen/MachineRegisterInfo.h" | ||
| #include "llvm/Support/Debug.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| #define DEBUG_TYPE "riscv-exegesis-post-processing" | ||
|
|
||
| namespace { | ||
| struct RISCVExegesisPostprocessing : public MachineFunctionPass { | ||
| static char ID; | ||
|
|
||
| RISCVExegesisPostprocessing() : MachineFunctionPass(ID) {} | ||
|
|
||
| bool runOnMachineFunction(MachineFunction &MF) override; | ||
|
|
||
| void getAnalysisUsage(AnalysisUsage &AU) const override { | ||
| AU.setPreservesCFG(); | ||
| MachineFunctionPass::getAnalysisUsage(AU); | ||
| } | ||
|
|
||
| private: | ||
| // Extremely simple register allocator that picks a register that hasn't | ||
| // been defined or used in this function. | ||
| Register allocateGPRRegister(const MachineFunction &MF, | ||
| const MachineRegisterInfo &MRI); | ||
|
|
||
| bool processVSETVL(MachineInstr &MI, MachineRegisterInfo &MRI); | ||
| bool processWriteFRM(MachineInstr &MI, MachineRegisterInfo &MRI); | ||
| }; | ||
| } // anonymous namespace | ||
|
|
||
| char RISCVExegesisPostprocessing::ID = 0; | ||
|
|
||
| bool RISCVExegesisPostprocessing::runOnMachineFunction(MachineFunction &MF) { | ||
| bool Changed = false; | ||
| for (auto &MBB : MF) | ||
| for (auto &MI : MBB) { | ||
| unsigned Opcode = MI.getOpcode(); | ||
| switch (Opcode) { | ||
| case RISCV::VSETVLI: | ||
| case RISCV::VSETVL: | ||
| case RISCV::PseudoVSETVLI: | ||
| case RISCV::PseudoVSETVLIX0: | ||
| Changed |= processVSETVL(MI, MF.getRegInfo()); | ||
| break; | ||
| case RISCV::SwapFRMImm: | ||
| case RISCV::WriteFRM: | ||
| Changed |= processWriteFRM(MI, MF.getRegInfo()); | ||
topperc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (Changed) | ||
| MF.getRegInfo().clearVirtRegs(); | ||
|
|
||
| LLVM_DEBUG(MF.print(dbgs() << "===After RISCVExegesisPostprocessing===\n"); | ||
| dbgs() << "\n"); | ||
|
|
||
| return Changed; | ||
| } | ||
|
|
||
| Register RISCVExegesisPostprocessing::allocateGPRRegister( | ||
| const MachineFunction &MF, const MachineRegisterInfo &MRI) { | ||
| const auto &TRI = *MRI.getTargetRegisterInfo(); | ||
|
|
||
| const TargetRegisterClass *GPRClass = | ||
| TRI.getRegClass(RISCV::GPRJALRRegClassID); | ||
topperc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| BitVector Candidates = TRI.getAllocatableSet(MF, GPRClass); | ||
|
|
||
| for (unsigned SetIdx : Candidates.set_bits()) { | ||
| if (MRI.reg_empty(Register(SetIdx))) | ||
| return Register(SetIdx); | ||
| } | ||
|
|
||
| // All bets are off, assign a fixed one. | ||
| return RISCV::X5; | ||
| } | ||
|
|
||
| bool RISCVExegesisPostprocessing::processVSETVL(MachineInstr &MI, | ||
| MachineRegisterInfo &MRI) { | ||
| bool Changed = false; | ||
| // Replace both AVL and VL (i.e. the result) operands with physical | ||
| // registers. | ||
| for (unsigned Idx = 0U; Idx < 2; ++Idx) | ||
| if (MI.getOperand(Idx).isReg()) { | ||
| Register RegOp = MI.getOperand(Idx).getReg(); | ||
| if (RegOp.isVirtual()) { | ||
| MRI.replaceRegWith(RegOp, allocateGPRRegister(*MI.getMF(), MRI)); | ||
| Changed = true; | ||
| } | ||
| } | ||
|
|
||
| return Changed; | ||
| } | ||
|
|
||
| bool RISCVExegesisPostprocessing::processWriteFRM(MachineInstr &MI, | ||
| MachineRegisterInfo &MRI) { | ||
| // The virtual register will be the first operand in both SwapFRMImm and | ||
| // WriteFRM. | ||
| if (MI.getOperand(0).isReg()) { | ||
topperc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Register DestReg = MI.getOperand(0).getReg(); | ||
| if (DestReg.isVirtual()) { | ||
| MRI.replaceRegWith(DestReg, allocateGPRRegister(*MI.getMF(), MRI)); | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| FunctionPass *llvm::exegesis::createRISCVPostprocessingPass() { | ||
| return new RISCVExegesisPostprocessing(); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.