Skip to content

Commit

Permalink
[RISCV] Remove Zbproposedc extension
Browse files Browse the repository at this point in the history
This consists of 3 compressed instructions, c.not, c.neg, and c.zext.w.
I believe these have been picked up by the Zce effort using different
encodings. I don't think it makes sense to keep them in bitmanip. It
will eventually cause a conflict if/when Zce is implemented in llvm.

Differential Revision: https://reviews.llvm.org/D110871
  • Loading branch information
topperc committed Sep 30, 2021
1 parent 962e503 commit a21c557
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 192 deletions.
6 changes: 0 additions & 6 deletions clang/lib/Basic/Targets/RISCV.cpp
Expand Up @@ -207,9 +207,6 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
if (HasZbp)
Builder.defineMacro("__riscv_zbp", "93000");

if (HasZbproposedc)
Builder.defineMacro("__riscv_zbproposedc", "93000");

if (HasZbr)
Builder.defineMacro("__riscv_zbr", "93000");

Expand Down Expand Up @@ -274,7 +271,6 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
.Case("experimental-zbf", HasZbf)
.Case("experimental-zbm", HasZbm)
.Case("experimental-zbp", HasZbp)
.Case("experimental-zbproposedc", HasZbproposedc)
.Case("experimental-zbr", HasZbr)
.Case("experimental-zbs", HasZbs)
.Case("experimental-zbt", HasZbt)
Expand Down Expand Up @@ -316,8 +312,6 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasZbm = true;
else if (Feature == "+experimental-zbp")
HasZbp = true;
else if (Feature == "+experimental-zbproposedc")
HasZbproposedc = true;
else if (Feature == "+experimental-zbr")
HasZbr = true;
else if (Feature == "+experimental-zbs")
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Basic/Targets/RISCV.h
Expand Up @@ -39,7 +39,6 @@ class RISCVTargetInfo : public TargetInfo {
bool HasZbf = false;
bool HasZbm = false;
bool HasZbp = false;
bool HasZbproposedc = false;
bool HasZbr = false;
bool HasZbs = false;
bool HasZbt = false;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Arch/RISCV.cpp
Expand Up @@ -60,7 +60,7 @@ static Optional<RISCVExtensionVersion>
isExperimentalExtension(StringRef Ext) {
if (Ext == "b" || Ext == "zba" || Ext == "zbb" || Ext == "zbc" ||
Ext == "zbe" || Ext == "zbf" || Ext == "zbm" || Ext == "zbp" ||
Ext == "zbr" || Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
Ext == "zbr" || Ext == "zbs" || Ext == "zbt")
return RISCVExtensionVersion{"0", "93"};
if (Ext == "v" || Ext == "zvamo" || Ext == "zvlsseg")
return RISCVExtensionVersion{"0", "10"};
Expand Down
10 changes: 0 additions & 10 deletions clang/test/Preprocessor/riscv-target-features.c
Expand Up @@ -25,7 +25,6 @@
// CHECK-NOT: __riscv_zbf
// CHECK-NOT: __riscv_zbm
// CHECK-NOT: __riscv_zbp
// CHECK-NOT: __riscv_zbproposedc
// CHECK-NOT: __riscv_zbr
// CHECK-NOT: __riscv_zbs
// CHECK-NOT: __riscv_zbt
Expand Down Expand Up @@ -182,15 +181,6 @@
// CHECK-ZBP-NOT: __riscv_b
// CHECK-ZBP-EXT: __riscv_zbp 93000

// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
// RUN: -march=rv32izbproposedc0p93 -x c -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZBPROPOSEDC-EXT %s
// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
// RUN: -march=rv32izbproposedc0p93 -x c -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZBPROPOSEDC-EXT %s
// CHECK-ZBPROPOSEDC-NOT: __riscv_b
// CHECK-ZBPROPOSEDC-EXT: __riscv_zbproposedc 93000

// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
// RUN: -march=rv32izbr0p93 -x c -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZBR-EXT %s
Expand Down
7 changes: 0 additions & 7 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Expand Up @@ -2078,8 +2078,6 @@ bool RISCVAsmParser::parseDirectiveAttribute() {
clearFeatureBits(RISCV::FeatureStdExtZbf, "experimental-zbf");
clearFeatureBits(RISCV::FeatureStdExtZbm, "experimental-zbm");
clearFeatureBits(RISCV::FeatureStdExtZbp, "experimental-zbp");
clearFeatureBits(RISCV::FeatureStdExtZbproposedc,
"experimental-zbproposedc");
clearFeatureBits(RISCV::FeatureStdExtZbr, "experimental-zbr");
clearFeatureBits(RISCV::FeatureStdExtZbs, "experimental-zbs");
clearFeatureBits(RISCV::FeatureStdExtZbt, "experimental-zbt");
Expand Down Expand Up @@ -2130,9 +2128,6 @@ bool RISCVAsmParser::parseDirectiveAttribute() {
setFeatureBits(RISCV::FeatureStdExtZbm, "experimental-zbm");
else if (Ext == "zbp")
setFeatureBits(RISCV::FeatureStdExtZbp, "experimental-zbp");
else if (Ext == "zbproposedc")
setFeatureBits(RISCV::FeatureStdExtZbproposedc,
"experimental-zbproposedc");
else if (Ext == "zbr")
setFeatureBits(RISCV::FeatureStdExtZbr, "experimental-zbr");
else if (Ext == "zbs")
Expand Down Expand Up @@ -2207,8 +2202,6 @@ bool RISCVAsmParser::parseDirectiveAttribute() {
formalArchStr = (Twine(formalArchStr) + "_zbm0p93").str();
if (getFeatureBits(RISCV::FeatureStdExtZbp))
formalArchStr = (Twine(formalArchStr) + "_zbp0p93").str();
if (getFeatureBits(RISCV::FeatureStdExtZbproposedc))
formalArchStr = (Twine(formalArchStr) + "_zbproposedc0p93").str();
if (getFeatureBits(RISCV::FeatureStdExtZbr))
formalArchStr = (Twine(formalArchStr) + "_zbr0p93").str();
if (getFeatureBits(RISCV::FeatureStdExtZbs))
Expand Down
13 changes: 0 additions & 13 deletions llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
Expand Up @@ -449,19 +449,6 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
}
}

if (STI.getFeatureBits()[RISCV::FeatureStdExtZbproposedc] &&
STI.getFeatureBits()[RISCV::FeatureStdExtC]) {
LLVM_DEBUG(
dbgs() << "Trying RVBC32 table (BitManip 16-bit Instruction):\n");
// Calling the auto-generated decoder function.
Result = decodeInstruction(DecoderTableRVBC16, MI, Insn, Address,
this, STI);
if (Result != MCDisassembler::Fail) {
Size = 2;
return Result;
}
}

LLVM_DEBUG(dbgs() << "Trying RISCV_C table (16-bit Instruction):\n");
// Calling the auto-generated decoder function.
Result = decodeInstruction(DecoderTable16, MI, Insn, Address, this, STI);
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
Expand Up @@ -80,8 +80,6 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI) {
Arch += "_zbm0p93";
if (STI.hasFeature(RISCV::FeatureStdExtZbp))
Arch += "_zbp0p93";
if (STI.hasFeature(RISCV::FeatureStdExtZbproposedc))
Arch += "_zbproposedc0p93";
if (STI.hasFeature(RISCV::FeatureStdExtZbr))
Arch += "_zbr0p93";
if (STI.hasFeature(RISCV::FeatureStdExtZbs))
Expand Down
7 changes: 0 additions & 7 deletions llvm/lib/Target/RISCV/RISCV.td
Expand Up @@ -135,13 +135,6 @@ def HasStdExtZbbOrZbp
"'Zbb' (Base 'B' Instructions) or "
"'Zbp' (Permutation 'B' Instructions)">;

def FeatureStdExtZbproposedc
: SubtargetFeature<"experimental-zbproposedc", "HasStdExtZbproposedc", "true",
"'Zbproposedc' (Proposed Compressed 'B' Instructions)">;
def HasStdExtZbproposedc : Predicate<"Subtarget->hasStdExtZbproposedc()">,
AssemblerPredicate<(all_of FeatureStdExtZbproposedc),
"'Zbproposedc' (Proposed Compressed 'B' Instructions)">;

def FeatureStdExtB
: SubtargetFeature<"experimental-b", "HasStdExtB", "true",
"'B' (Bit Manipulation Instructions)",
Expand Down
46 changes: 0 additions & 46 deletions llvm/lib/Target/RISCV/RISCVInstrInfoB.td
Expand Up @@ -610,37 +610,6 @@ def ORCB : RVInstI<0b101, OPC_OP_IMM, (outs GPR:$rd), (ins GPR:$rs1),
}
} // Predicates = [HasStdExtZbbOrZbp]

//===----------------------------------------------------------------------===//
// Future compressed instructions
//===----------------------------------------------------------------------===//

// The presence of these instructions in the B extension is purely experimental
// and they should be moved to the C extension as soon as they are ratified.

let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
class RVBInstC<bits<2> funct2, string opcodestr>
: RVInst16<(outs GPRC:$rs_wb), (ins GPRC:$rs), opcodestr, "$rs", [],
InstFormatCR> {
bits<3> rs;
let Constraints = "$rs = $rs_wb";

let Inst{15-12} = 0b0110;
let Inst{11-10} = funct2;
let Inst{9-7} = rs;
let Inst{6-0} = 0b0000001;
}

// The namespace RVBC exists to avoid encoding conflicts with the compressed
// instructions c.addi16sp and c.lui already implemented in the C extension.

let DecoderNamespace = "RVBC", Predicates = [HasStdExtZbproposedc, HasStdExtC] in {
def C_NOT : RVBInstC<0b00, "c.not">, Sched<[]>;
def C_NEG : RVBInstC<0b01, "c.neg">, Sched<[]>;
} // DecoderNamespace = "RVBC", Predicates = [HasStdExtZbproposedc, HasStdExtC]

let DecoderNamespace = "RVBC", Predicates = [HasStdExtZbproposedc, HasStdExtZba, HasStdExtC, IsRV64] in
def C_ZEXTW : RVBInstC<0b10, "c.zext.w">, Sched<[]>;

//===----------------------------------------------------------------------===//
// Pseudo Instructions
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -795,21 +764,6 @@ def : InstAlias<"bext $rd, $rs1, $shamt",
(BEXTI GPR:$rd, GPR:$rs1, uimmlog2xlen:$shamt), 0>;
} // Predicates = [HasStdExtZbs]

//===----------------------------------------------------------------------===//
// Compressed Instruction patterns
//===----------------------------------------------------------------------===//
let Predicates = [HasStdExtZbproposedc, HasStdExtC] in {
def : CompressPat<(XORI GPRC:$rs1, GPRC:$rs1, -1),
(C_NOT GPRC:$rs1)>;
def : CompressPat<(SUB GPRC:$rs1, X0, GPRC:$rs1),
(C_NEG GPRC:$rs1)>;
} // Predicates = [HasStdExtZbproposedc, HasStdExtC]

let Predicates = [HasStdExtZbproposedc, HasStdExtZba, HasStdExtC, IsRV64] in {
def : CompressPat<(ADDUW GPRC:$rs1, GPRC:$rs1, X0),
(C_ZEXTW GPRC:$rs1)>;
} // Predicates = [HasStdExtZbproposedc, HasStdExtC, IsRV64]

//===----------------------------------------------------------------------===//
// Codegen patterns
//===----------------------------------------------------------------------===//
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Target/RISCV/RISCVSubtarget.h
Expand Up @@ -50,7 +50,6 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
bool HasStdExtZbr = false;
bool HasStdExtZbs = false;
bool HasStdExtZbt = false;
bool HasStdExtZbproposedc = false;
bool HasStdExtV = false;
bool HasStdExtZvlsseg = false;
bool HasStdExtZvamo = false;
Expand Down Expand Up @@ -118,7 +117,6 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
bool hasStdExtZbr() const { return HasStdExtZbr; }
bool hasStdExtZbs() const { return HasStdExtZbs; }
bool hasStdExtZbt() const { return HasStdExtZbt; }
bool hasStdExtZbproposedc() const { return HasStdExtZbproposedc; }
bool hasStdExtV() const { return HasStdExtV; }
bool hasStdExtZvlsseg() const { return HasStdExtZvlsseg; }
bool hasStdExtZvamo() const { return HasStdExtZvamo; }
Expand Down
4 changes: 0 additions & 4 deletions llvm/test/CodeGen/RISCV/attributes.ll
Expand Up @@ -15,7 +15,6 @@
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbf %s -o - | FileCheck --check-prefix=RV32ZBF %s
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbm %s -o - | FileCheck --check-prefix=RV32ZBM %s
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbp %s -o - | FileCheck --check-prefix=RV32ZBP %s
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbproposedc %s -o - | FileCheck --check-prefix=RV32ZBPROPOSEDC %s
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbr %s -o - | FileCheck --check-prefix=RV32ZBR %s
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV32ZBS %s
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV32ZBT %s
Expand All @@ -35,7 +34,6 @@
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbf %s -o - | FileCheck --check-prefix=RV64ZBF %s
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbm %s -o - | FileCheck --check-prefix=RV64ZBM %s
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbp %s -o - | FileCheck --check-prefix=RV64ZBP %s
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbproposedc %s -o - | FileCheck --check-prefix=RV64ZBPROPOSEDC %s
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbr %s -o - | FileCheck --check-prefix=RV64ZBR %s
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV64ZBS %s
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV64ZBT %s
Expand All @@ -56,7 +54,6 @@
; RV32ZBF: .attribute 5, "rv32i2p0_zbf0p93"
; RV32ZBM: .attribute 5, "rv32i2p0_zbm0p93"
; RV32ZBP: .attribute 5, "rv32i2p0_zbp0p93"
; RV32ZBPROPOSEDC: .attribute 5, "rv32i2p0_zbproposedc0p93"
; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
Expand All @@ -76,7 +73,6 @@
; RV64ZBF: .attribute 5, "rv64i2p0_zbf0p93"
; RV64ZBM: .attribute 5, "rv64i2p0_zbm0p93"
; RV64ZBP: .attribute 5, "rv64i2p0_zbp0p93"
; RV64ZBPROPOSEDC: .attribute 5, "rv64i2p0_zbproposedc0p93"
; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
Expand Down
3 changes: 0 additions & 3 deletions llvm/test/MC/RISCV/attribute-arch.s
Expand Up @@ -63,9 +63,6 @@
.attribute arch, "rv32izbp"
# CHECK: attribute 5, "rv32i2p0_zbp0p93"

.attribute arch, "rv32izbproposedc"
# CHECK: attribute 5, "rv32i2p0_zbproposedc0p93"

.attribute arch, "rv32izbr"
# CHECK: attribute 5, "rv32i2p0_zbr0p93"

Expand Down
35 changes: 0 additions & 35 deletions llvm/test/MC/RISCV/compress-rv32b.s

This file was deleted.

18 changes: 0 additions & 18 deletions llvm/test/MC/RISCV/compress-rv64b.s

This file was deleted.

6 changes: 0 additions & 6 deletions llvm/test/MC/RISCV/rv32zbproposedc-invalid.s

This file was deleted.

17 changes: 0 additions & 17 deletions llvm/test/MC/RISCV/rv32zbproposedc-valid.s

This file was deleted.

4 changes: 0 additions & 4 deletions llvm/test/MC/RISCV/rv64zbproposedc-invalid.s

This file was deleted.

10 changes: 0 additions & 10 deletions llvm/test/MC/RISCV/rv64zbproposedc-valid.s

This file was deleted.

0 comments on commit a21c557

Please sign in to comment.