Skip to content

Commit

Permalink
[RISCV][NFC] Move Zawrs/Zacas implementation to RISCVInstrInfoZa.td
Browse files Browse the repository at this point in the history
To keep the structure of TableGen files clear.

The definitions are simplified by the way.
  • Loading branch information
wangpc-pp committed Jan 5, 2024
1 parent 6ae7f66 commit c4e2d02
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
17 changes: 1 addition & 16 deletions llvm/lib/Target/RISCV/RISCVInstrInfo.td
Expand Up @@ -729,22 +729,6 @@ def UNIMP : RVInstI<0b001, OPC_SYSTEM, (outs), (ins), "unimp", "">,
let imm12 = 0b110000000000;
}

let Predicates = [HasStdExtZawrs] in {
def WRS_NTO : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "wrs.nto", "">,
Sched<[]> {
let rs1 = 0;
let rd = 0;
let imm12 = 0b000000001101;
}

def WRS_STO : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "wrs.sto", "">,
Sched<[]> {
let rs1 = 0;
let rd = 0;
let imm12 = 0b000000011101;
}
} // Predicates = [HasStdExtZawrs]

} // hasSideEffects = 1, mayLoad = 0, mayStore = 0

def CSRRW : CSR_ir<0b001, "csrrw">;
Expand Down Expand Up @@ -2095,6 +2079,7 @@ include "RISCVInstrInfoM.td"

// Atomic
include "RISCVInstrInfoA.td"
include "RISCVInstrInfoZa.td"

// Scalar FP
include "RISCVInstrInfoF.td"
Expand Down
12 changes: 1 addition & 11 deletions llvm/lib/Target/RISCV/RISCVInstrInfoA.td
Expand Up @@ -7,8 +7,7 @@
//===----------------------------------------------------------------------===//
//
// This file describes the RISC-V instructions from the standard 'A', Atomic
// Instructions extension as well as the experimental 'Zacas' (Atomic
// Compare-and-Swap) extension.
// Instructions extension.
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -96,15 +95,6 @@ defm AMOMAXU_D : AMO_rr_aq_rl<0b11100, 0b011, "amomaxu.d">,
Sched<[WriteAtomicD, ReadAtomicDA, ReadAtomicDD]>;
} // Predicates = [HasStdExtA, IsRV64]

let Predicates = [HasStdExtZacas] in {
defm AMOCAS_W : AMO_rr_aq_rl<0b00101, 0b010, "amocas.w">;
defm AMOCAS_D : AMO_rr_aq_rl<0b00101, 0b011, "amocas.d">;
} // Predicates = [HasStdExtZacas]

let Predicates = [HasStdExtZacas, IsRV64] in {
defm AMOCAS_Q : AMO_rr_aq_rl<0b00101, 0b100, "amocas.q">;
} // Predicates = [HasStdExtZacas, IsRV64]

//===----------------------------------------------------------------------===//
// Pseudo-instructions and codegen patterns
//===----------------------------------------------------------------------===//
Expand Down
44 changes: 44 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZa.td
@@ -0,0 +1,44 @@
//===-- RISCVInstrInfoZa.td - RISC-V Atomic instructions ---*- 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 atomic 'Za*'
// extensions:
// - Zawrs (v1.0) : Wait-on-Reservation-Set.
// - Zacas (v1.0-rc1) : Atomic Compare-and-Swap.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Zacas (Atomic Compare-and-Swap)
//===----------------------------------------------------------------------===//

let Predicates = [HasStdExtZacas] in {
defm AMOCAS_W : AMO_rr_aq_rl<0b00101, 0b010, "amocas.w">;
defm AMOCAS_D : AMO_rr_aq_rl<0b00101, 0b011, "amocas.d">;
} // Predicates = [HasStdExtZacas]

let Predicates = [HasStdExtZacas, IsRV64] in {
defm AMOCAS_Q : AMO_rr_aq_rl<0b00101, 0b100, "amocas.q">;
} // Predicates = [HasStdExtZacas, IsRV64]

//===----------------------------------------------------------------------===//
// Zawrs (Wait-on-Reservation-Set)
//===----------------------------------------------------------------------===//

let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
class WRSInst<bits<12> funct12, string opcodestr>
: RVInstI<0b000, OPC_SYSTEM, (outs), (ins), opcodestr, ""> {
let rs1 = 0;
let rd = 0;
let imm12 = funct12;
}

let Predicates = [HasStdExtZawrs] in {
def WRS_NTO : WRSInst<0b000000001101, "wrs.nto">, Sched<[]>;
def WRS_STO : WRSInst<0b000000011101, "wrs.sto">, Sched<[]>;
} // Predicates = [HasStdExtZawrs]

0 comments on commit c4e2d02

Please sign in to comment.