-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV] Add Zilsd and Zclsd Extensions #131094
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 37 commits
bcdf964
30e3fbe
e41e745
ea2c1af
6b074f3
f77d8e3
58a1fe2
17b994b
6f57575
2c3440f
faa59c9
4442de0
20fd842
1fb709c
5a6103d
f7c4cf4
54780fa
1387e89
fc52464
7f61fd6
2df1bbf
ff30cde
10c800c
f7cf00f
b07f830
e478e03
2262393
8a2fd1d
9972069
613cf3a
95ddfa1
a61e604
bf6ea39
4158069
cc7a33c
1c59ebc
3b7e25e
faec63f
dfda4ae
e17ca63
4b1709e
68c3845
d0a4e32
89f5a20
31b55e8
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -176,6 +176,13 @@ def HasStdExtZicfiss : Predicate<"Subtarget->hasStdExtZicfiss()">, | |||||
| "'Zicfiss' (Shadow stack)">; | ||||||
| def NoHasStdExtZicfiss : Predicate<"!Subtarget->hasStdExtZicfiss()">; | ||||||
|
|
||||||
| def FeatureStdExtZilsd | ||||||
| : RISCVExtension<1, 0, | ||||||
| "Load/Store Pair Instructions">; | ||||||
wangpc-pp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| def HasStdExtZilsd : Predicate<"Subtarget->hasStdExtZilsd()">, | ||||||
| AssemblerPredicate<(all_of FeatureStdExtZilsd), | ||||||
| "'Zilsd' (Load/Store pair instructions)">; | ||||||
|
|
||||||
| // Multiply Extensions | ||||||
|
|
||||||
| def FeatureStdExtZmmul | ||||||
|
|
@@ -401,6 +408,14 @@ def FeatureStdExtZcf | |||||
| "Compressed Single-Precision Floating-Point Instructions", | ||||||
| [FeatureStdExtF, FeatureStdExtZca]>; | ||||||
|
|
||||||
| def FeatureStdExtZclsd | ||||||
| : RISCVExtension<1, 0, | ||||||
| "Compressed Load/Store Pair Instructions", | ||||||
| [FeatureStdExtZilsd,FeatureStdExtZca]>; | ||||||
| def HasStdExtZclsd : Predicate<"Subtarget->hasStdExtZclsd() && !Subtarget->hasStdExtZcf()">, | ||||||
|
||||||
| def HasStdExtZclsd : Predicate<"Subtarget->hasStdExtZclsd() && !Subtarget->hasStdExtZcf()">, | |
| def HasStdExtZclsd : Predicate<"Subtarget->hasStdExtZclsd()">, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| //===-- RISCVInstrInfoZclsd.td -----------------------------*- tablegen -*-===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file describes the RISC-V instructions from the standard 'Zclsd', | ||
| // Compressed Load/Store pair instructions extension. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instruction Class Templates | ||
dong-miao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def GPRPairNoX0RV32Operand : AsmOperandClass { | ||
| let Name = "GPRPairNoX0RV32"; | ||
| let ParserMethod = "parseGPRPair<false>"; | ||
| let PredicateMethod = "isGPRPairNoX0"; | ||
| let RenderMethod = "addRegOperands"; | ||
| } | ||
|
|
||
| def GPRPairNoX0RV32 : RegisterOperand<GPRPairNoX0> { | ||
| let ParserMatchClass = GPRPairNoX0RV32Operand; | ||
| } | ||
|
|
||
| def GPRPairCRV32Operand : AsmOperandClass { | ||
| let Name = "GPRPairCRV32"; | ||
| let ParserMethod = "parseGPRPair<false>"; | ||
| let PredicateMethod = "isGPRPairC"; | ||
| let RenderMethod = "addRegOperands"; | ||
| } | ||
|
|
||
| def GPRPairCRV32 : RegisterOperand<GPRPairC> { | ||
| let ParserMatchClass = GPRPairCRV32Operand; | ||
| } | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in | ||
| class PairCStackLoad<bits<3> funct3, string OpcodeStr, | ||
| DAGOperand RC, DAGOperand opnd> | ||
dong-miao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| : RVInst16CI<funct3, 0b10, (outs RC:$rd), (ins SPMem:$rs1, opnd:$imm), | ||
| OpcodeStr, "$rd, ${imm}(${rs1})">; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in | ||
| class PairCStackStore<bits<3> funct3, string OpcodeStr, | ||
| DAGOperand RC, DAGOperand opnd> | ||
| : RVInst16CSS<funct3, 0b10, (outs), (ins RC:$rs2, SPMem:$rs1, opnd:$imm), | ||
| OpcodeStr, "$rs2, ${imm}(${rs1})">; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in | ||
| class PairCLoad_ri<bits<3> funct3, string OpcodeStr, | ||
| DAGOperand RC, DAGOperand opnd> | ||
| : RVInst16CL<funct3, 0b00, (outs RC:$rd), (ins GPRCMem:$rs1, opnd:$imm), | ||
| OpcodeStr, "$rd, ${imm}(${rs1})">; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in | ||
| class PairCStore_rri<bits<3> funct3, string OpcodeStr, | ||
| DAGOperand RC, DAGOperand opnd> | ||
| : RVInst16CS<funct3, 0b00, (outs), (ins RC:$rs2,GPRCMem:$rs1, opnd:$imm), | ||
| OpcodeStr, "$rs2, ${imm}(${rs1})">; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instructions | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap" in | ||
| def C_LDSP_RV32 : PairCStackLoad<0b011, "c.ldsp", GPRPairNoX0RV32, uimm9_lsb000>, | ||
| Sched<[WriteLDD, ReadMemBase]> { | ||
| let Inst{4-2} = imm{8-6}; | ||
| } | ||
|
|
||
| let Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap" in | ||
dong-miao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def C_SDSP_RV32 : PairCStackStore<0b111, "c.sdsp", GPRPairRV32, uimm9_lsb000>, | ||
| Sched<[WriteSTD, ReadStoreData, ReadMemBase]> { | ||
| let Inst{9-7} = imm{8-6}; | ||
| } | ||
|
|
||
| let Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap" in | ||
| def C_LD_RV32 : PairCLoad_ri<0b011, "c.ld", GPRPairCRV32, uimm8_lsb000>, | ||
| Sched<[WriteLDD, ReadMemBase]> { | ||
| bits<8> imm; | ||
| let Inst{12-10} = imm{5-3}; | ||
| let Inst{6-5} = imm{7-6}; | ||
| } | ||
|
|
||
| let Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap" in | ||
| def C_SD_RV32 : PairCStore_rri<0b111, "c.sd", GPRPairCRV32, uimm8_lsb000>, | ||
| Sched<[WriteSTD, ReadStoreData, ReadMemBase]> { | ||
| bits<8> imm; | ||
| let Inst{12-10} = imm{5-3}; | ||
| let Inst{6-5} = imm{7-6}; | ||
| }// Predicates = [HasStdExtZclsd, IsRV32] | ||
dong-miao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Compress Instruction tablegen backend. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let Predicates = [HasStdExtZclsd, HasStdExtZilsd, IsRV32] in { | ||
dong-miao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def : CompressPat<(LD_RV32 GPRPairNoX0RV32:$rd, SPMem:$rs1, uimm9_lsb000:$imm), | ||
| (C_LDSP_RV32 GPRPairNoX0RV32:$rd, SPMem:$rs1, uimm9_lsb000:$imm)>; | ||
| def : CompressPat<(SD_RV32 GPRPairRV32:$rs2, SPMem:$rs1, uimm9_lsb000:$imm), | ||
| (C_SDSP_RV32 GPRPairRV32:$rs2, SPMem:$rs1, uimm9_lsb000:$imm)>; | ||
| } // Predicates = [HasStdExtZclsd, HasStdExtZilsd, IsRV32] | ||
|
|
||
| let Predicates = [HasStdExtZclsd, HasStdExtZilsd, IsRV32] in { | ||
dong-miao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def : CompressPat<(LD_RV32 GPRPairCRV32:$rd, GPRCMem:$rs1, uimm8_lsb000:$imm), | ||
| (C_LD_RV32 GPRPairCRV32:$rd, GPRCMem:$rs1, uimm8_lsb000:$imm)>; | ||
| def : CompressPat<(SD_RV32 GPRPairCRV32:$rs2, GPRCMem:$rs1, uimm8_lsb000:$imm), | ||
| (C_SD_RV32 GPRPairCRV32:$rs2, GPRCMem:$rs1, uimm8_lsb000:$imm)>; | ||
| } // Predicates = [HasStdExtZclsd, HasStdExtZilsd, IsRV32] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| //===-- RISCVInstrInfoZilsd.td -----------------------------*- tablegen -*-===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file describes the RISC-V instructions from the standard 'Zilsd', | ||
| // Load/Store pair instructions extension. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instruction Class Templates | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in | ||
| class PairLoad_ri<string opcodestr, DAGOperand RC> | ||
| : RVInstI<0b011, OPC_LOAD, (outs RC:$rd), | ||
| (ins GPRMem:$rs1, simm12:$imm12), | ||
| opcodestr, "${rd}, ${imm12}(${rs1})">; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in | ||
| class PairStore_rri<string opcodestr, DAGOperand RC> | ||
| : RVInstS<0b011, OPC_STORE, (outs), | ||
| (ins RC:$rs2, GPRMem:$rs1, simm12:$imm12), | ||
| opcodestr, "${rs2}, ${imm12}(${rs1})">; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instructions | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let Predicates = [HasStdExtZilsd, IsRV32], DecoderNamespace = "RV32GPRPair" in { | ||
| def LD_RV32 : PairLoad_ri<"ld", GPRPairRV32>, Sched<[WriteLDD, ReadMemBase]>; | ||
| def SD_RV32 : PairStore_rri<"sd", GPRPairRV32>, Sched<[WriteSTD, ReadStoreData, ReadMemBase]>; | ||
dong-miao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } // Predicates = [HasStdExtZilsd, IsRV32] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # RUN: not llvm-mc -triple=riscv32 -mattr=+zclsd < %s 2>&1 | FileCheck %s | ||
|
|
||
| ## GPRPairC | ||
| c.ld t1, 4(sp) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction | ||
| c.sd s2, 4(sp) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction | ||
|
|
||
| ## GPRPairNoX0 | ||
| c.ldsp x0, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction | ||
| c.ldsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction | ||
|
|
||
| ## uimm9_lsb000 | ||
| c.ldsp t1, 512(sp) # CHECK: :[[@LINE]]:12: error: immediate must be a multiple of 8 bytes in the range [0, 504] | ||
| c.sdsp t1, -8(sp) # CHECK: :[[@LINE]]:12: error: immediate must be a multiple of 8 bytes in the range [0, 504] | ||
| ## uimm8_lsb000 | ||
| c.ld s0, -8(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248] | ||
| c.sd s0, 256(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248] | ||
|
|
||
| # Invalid register names | ||
| c.ld a1, 4(sp) # CHECK: :[[@LINE]]:6: error: register must be even | ||
| c.sd a3, 4(sp) # CHECK: :[[@LINE]]:6: error: register must be even | ||
| c.ldsp ra, 4(sp) # CHECK: :[[@LINE]]:8: error: register must be even | ||
| c.ldsp t0, 4(sp) # CHECK: :[[@LINE]]:8: error: register must be even |
Uh oh!
There was an error while loading. Please reload this page.