xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/RISCV.td (revision 8bcb0991864975618c09697b1aca10683346d9f0)
10b57cec5SDimitry Andric//===-- RISCV.td - Describe the RISCV Target Machine -------*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andricinclude "llvm/Target/Target.td"
100b57cec5SDimitry Andric
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric// RISC-V subtarget features and instruction predicates.
130b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
140b57cec5SDimitry Andric
150b57cec5SDimitry Andricdef FeatureStdExtM
160b57cec5SDimitry Andric    : SubtargetFeature<"m", "HasStdExtM", "true",
170b57cec5SDimitry Andric                       "'M' (Integer Multiplication and Division)">;
180b57cec5SDimitry Andricdef HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
190b57cec5SDimitry Andric                           AssemblerPredicate<"FeatureStdExtM">;
200b57cec5SDimitry Andric
210b57cec5SDimitry Andricdef FeatureStdExtA
220b57cec5SDimitry Andric    : SubtargetFeature<"a", "HasStdExtA", "true",
230b57cec5SDimitry Andric                       "'A' (Atomic Instructions)">;
240b57cec5SDimitry Andricdef HasStdExtA : Predicate<"Subtarget->hasStdExtA()">,
250b57cec5SDimitry Andric                           AssemblerPredicate<"FeatureStdExtA">;
260b57cec5SDimitry Andric
270b57cec5SDimitry Andricdef FeatureStdExtF
280b57cec5SDimitry Andric    : SubtargetFeature<"f", "HasStdExtF", "true",
290b57cec5SDimitry Andric                       "'F' (Single-Precision Floating-Point)">;
300b57cec5SDimitry Andricdef HasStdExtF : Predicate<"Subtarget->hasStdExtF()">,
310b57cec5SDimitry Andric                           AssemblerPredicate<"FeatureStdExtF">;
320b57cec5SDimitry Andric
330b57cec5SDimitry Andricdef FeatureStdExtD
340b57cec5SDimitry Andric    : SubtargetFeature<"d", "HasStdExtD", "true",
350b57cec5SDimitry Andric                       "'D' (Double-Precision Floating-Point)",
360b57cec5SDimitry Andric                       [FeatureStdExtF]>;
370b57cec5SDimitry Andricdef HasStdExtD : Predicate<"Subtarget->hasStdExtD()">,
380b57cec5SDimitry Andric                           AssemblerPredicate<"FeatureStdExtD">;
390b57cec5SDimitry Andric
400b57cec5SDimitry Andricdef FeatureStdExtC
410b57cec5SDimitry Andric    : SubtargetFeature<"c", "HasStdExtC", "true",
420b57cec5SDimitry Andric                       "'C' (Compressed Instructions)">;
430b57cec5SDimitry Andricdef HasStdExtC : Predicate<"Subtarget->hasStdExtC()">,
440b57cec5SDimitry Andric                           AssemblerPredicate<"FeatureStdExtC">;
450b57cec5SDimitry Andric
46*8bcb0991SDimitry Andricdef FeatureRVCHints
47*8bcb0991SDimitry Andric    : SubtargetFeature<"rvc-hints", "EnableRVCHintInstrs", "true",
48*8bcb0991SDimitry Andric                       "Enable RVC Hint Instructions.">;
49*8bcb0991SDimitry Andricdef HasRVCHints : Predicate<"Subtarget->enableRVCHintInstrs()">,
50*8bcb0991SDimitry Andric                            AssemblerPredicate<"FeatureRVCHints">;
510b57cec5SDimitry Andric
520b57cec5SDimitry Andricdef Feature64Bit
530b57cec5SDimitry Andric    : SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">;
540b57cec5SDimitry Andricdef IsRV64 : Predicate<"Subtarget->is64Bit()">,
550b57cec5SDimitry Andric                       AssemblerPredicate<"Feature64Bit">;
560b57cec5SDimitry Andricdef IsRV32 : Predicate<"!Subtarget->is64Bit()">,
570b57cec5SDimitry Andric                       AssemblerPredicate<"!Feature64Bit">;
580b57cec5SDimitry Andric
590b57cec5SDimitry Andricdef RV64           : HwMode<"+64bit">;
600b57cec5SDimitry Andricdef RV32           : HwMode<"-64bit">;
610b57cec5SDimitry Andric
620b57cec5SDimitry Andricdef FeatureRV32E
630b57cec5SDimitry Andric    : SubtargetFeature<"e", "IsRV32E", "true",
640b57cec5SDimitry Andric                       "Implements RV32E (provides 16 rather than 32 GPRs)">;
650b57cec5SDimitry Andricdef IsRV32E : Predicate<"Subtarget->isRV32E()">,
660b57cec5SDimitry Andric                        AssemblerPredicate<"FeatureRV32E">;
670b57cec5SDimitry Andric
680b57cec5SDimitry Andricdef FeatureRelax
690b57cec5SDimitry Andric    : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
700b57cec5SDimitry Andric                       "Enable Linker relaxation.">;
710b57cec5SDimitry Andric
720b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
730b57cec5SDimitry Andric// Named operands for CSR instructions.
740b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
750b57cec5SDimitry Andric
760b57cec5SDimitry Andricinclude "RISCVSystemOperands.td"
770b57cec5SDimitry Andric
780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
790b57cec5SDimitry Andric// Registers, calling conventions, instruction descriptions.
800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
810b57cec5SDimitry Andric
820b57cec5SDimitry Andricinclude "RISCVRegisterInfo.td"
830b57cec5SDimitry Andricinclude "RISCVCallingConv.td"
840b57cec5SDimitry Andricinclude "RISCVInstrInfo.td"
85*8bcb0991SDimitry Andricinclude "RISCVRegisterBanks.td"
860b57cec5SDimitry Andric
870b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
880b57cec5SDimitry Andric// RISC-V processors supported.
890b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
900b57cec5SDimitry Andric
91*8bcb0991SDimitry Andricdef : ProcessorModel<"generic-rv32", NoSchedModel, [FeatureRVCHints]>;
920b57cec5SDimitry Andric
93*8bcb0991SDimitry Andricdef : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit,
94*8bcb0991SDimitry Andric                     FeatureRVCHints]>;
950b57cec5SDimitry Andric
960b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
970b57cec5SDimitry Andric// Define the RISC-V target.
980b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
990b57cec5SDimitry Andric
1000b57cec5SDimitry Andricdef RISCVInstrInfo : InstrInfo {
1010b57cec5SDimitry Andric  let guessInstructionProperties = 0;
1020b57cec5SDimitry Andric}
1030b57cec5SDimitry Andric
1040b57cec5SDimitry Andricdef RISCVAsmParser : AsmParser {
1050b57cec5SDimitry Andric  let ShouldEmitMatchRegisterAltName = 1;
1060b57cec5SDimitry Andric  let AllowDuplicateRegisterNames = 1;
1070b57cec5SDimitry Andric}
1080b57cec5SDimitry Andric
1090b57cec5SDimitry Andricdef RISCVAsmWriter : AsmWriter {
1100b57cec5SDimitry Andric  int PassSubtarget = 1;
1110b57cec5SDimitry Andric}
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andricdef RISCV : Target {
1140b57cec5SDimitry Andric  let InstructionSet = RISCVInstrInfo;
1150b57cec5SDimitry Andric  let AssemblyParsers = [RISCVAsmParser];
1160b57cec5SDimitry Andric  let AssemblyWriters = [RISCVAsmWriter];
1170b57cec5SDimitry Andric  let AllowRegisterRenaming = 1;
1180b57cec5SDimitry Andric}
119