-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[RISCV] GISel custom lowering for G_ADD/G_SUB #121587
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| #include "llvm/CodeGen/MachineConstantPool.h" | ||
| #include "llvm/CodeGen/MachineJumpTableInfo.h" | ||
| #include "llvm/CodeGen/MachineMemOperand.h" | ||
| #include "llvm/CodeGen/MachineOperand.h" | ||
| #include "llvm/CodeGen/MachineRegisterInfo.h" | ||
| #include "llvm/CodeGen/TargetOpcodes.h" | ||
| #include "llvm/CodeGen/ValueTypes.h" | ||
|
|
@@ -132,7 +133,14 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) | |
|
|
||
| auto PtrVecTys = {nxv1p0, nxv2p0, nxv4p0, nxv8p0, nxv16p0}; | ||
|
|
||
| getActionDefinitionsBuilder({G_ADD, G_SUB, G_AND, G_OR, G_XOR}) | ||
| getActionDefinitionsBuilder({G_ADD, G_SUB}) | ||
| .legalFor({sXLen}) | ||
| .legalIf(typeIsLegalIntOrFPVec(0, IntOrFPVecTys, ST)) | ||
| .customFor(ST.is64Bit(), {s32}) | ||
| .widenScalarToNextPow2(0) | ||
| .clampScalar(0, sXLen, sXLen); | ||
|
|
||
| getActionDefinitionsBuilder({G_AND, G_OR, G_XOR}) | ||
| .legalFor({sXLen}) | ||
| .legalIf(typeIsLegalIntOrFPVec(0, IntOrFPVecTys, ST)) | ||
| .widenScalarToNextPow2(0) | ||
|
|
@@ -1330,6 +1338,25 @@ bool RISCVLegalizerInfo::legalizeCustom( | |
| return true; | ||
| return Helper.lowerConstant(MI); | ||
| } | ||
| case TargetOpcode::G_SUB: | ||
| case TargetOpcode::G_ADD: { | ||
| Helper.Observer.changingInstr(MI); | ||
| Helper.widenScalarSrc(MI, LLT::scalar(64), 1, TargetOpcode::G_ANYEXT); | ||
| Helper.widenScalarSrc(MI, LLT::scalar(64), 2, TargetOpcode::G_ANYEXT); | ||
|
|
||
| Register DstALU = MRI.createGenericVirtualRegister(sXLen); | ||
| Register DstSext = MRI.createGenericVirtualRegister(sXLen); | ||
|
||
|
|
||
| MachineOperand &MO = MI.getOperand(0); | ||
| MIRBuilder.setInsertPt(MIRBuilder.getMBB(), ++MIRBuilder.getInsertPt()); | ||
| MIRBuilder.buildSExtInReg(DstSext, DstALU, 32); | ||
|
|
||
| MIRBuilder.buildInstr(TargetOpcode::G_TRUNC, {MO}, {DstSext}); | ||
| MO.setReg(DstALU); | ||
|
|
||
| Helper.Observer.changedInstr(MI); | ||
| return true; | ||
| } | ||
| case TargetOpcode::G_SEXT_INREG: { | ||
| LLT DstTy = MRI.getType(MI.getOperand(0).getReg()); | ||
| int64_t SizeInBits = MI.getOperand(2).getImm(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.