blob: 3936da677a5f18532fbf77cd1abf1ce35eaebd02 [file] [log] [blame]
Alex Bradbury24d9b132016-11-01 23:40:28 +00001//===-- RISCV.td - Describe the RISCV Target Machine -------*- tablegen -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Alex Bradbury24d9b132016-11-01 23:40:28 +00006//
7//===----------------------------------------------------------------------===//
8
9include "llvm/Target/Target.td"
10
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000011//===----------------------------------------------------------------------===//
12// RISC-V subtarget features and instruction predicates.
13//===----------------------------------------------------------------------===//
14
Alex Bradbury8c345c52017-11-09 15:00:03 +000015def FeatureStdExtM
16 : SubtargetFeature<"m", "HasStdExtM", "true",
17 "'M' (Integer Multiplication and Division)">;
18def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
Alex Bradburya47514c2017-11-09 14:46:30 +000019 AssemblerPredicate<"FeatureStdExtM">;
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000020
Alex Bradbury8c345c52017-11-09 15:00:03 +000021def FeatureStdExtA
22 : SubtargetFeature<"a", "HasStdExtA", "true",
23 "'A' (Atomic Instructions)">;
24def HasStdExtA : Predicate<"Subtarget->hasStdExtA()">,
25 AssemblerPredicate<"FeatureStdExtA">;
26
Alex Bradbury0d6cf902017-12-07 10:26:05 +000027def FeatureStdExtF
28 : SubtargetFeature<"f", "HasStdExtF", "true",
29 "'F' (Single-Precision Floating-Point)">;
30def HasStdExtF : Predicate<"Subtarget->hasStdExtF()">,
31 AssemblerPredicate<"FeatureStdExtF">;
32
Alex Bradbury7bc2a952017-12-07 10:46:23 +000033def FeatureStdExtD
34 : SubtargetFeature<"d", "HasStdExtD", "true",
35 "'D' (Double-Precision Floating-Point)",
36 [FeatureStdExtF]>;
37def HasStdExtD : Predicate<"Subtarget->hasStdExtD()">,
38 AssemblerPredicate<"FeatureStdExtD">;
39
Alex Bradbury9f6aec42017-12-07 12:50:32 +000040def FeatureStdExtC
41 : SubtargetFeature<"c", "HasStdExtC", "true",
42 "'C' (Compressed Instructions)">;
43def HasStdExtC : Predicate<"Subtarget->hasStdExtC()">,
44 AssemblerPredicate<"FeatureStdExtC">;
45
46
Alex Bradbury8c345c52017-11-09 15:00:03 +000047def Feature64Bit
48 : SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">;
Alex Bradburya6e62482017-12-07 10:53:48 +000049def IsRV64 : Predicate<"Subtarget->is64Bit()">,
50 AssemblerPredicate<"Feature64Bit">;
Alex Bradbury9ed84c82017-12-12 15:46:15 +000051def IsRV32 : Predicate<"!Subtarget->is64Bit()">,
52 AssemblerPredicate<"!Feature64Bit">;
Alex Bradburya47514c2017-11-09 14:46:30 +000053
54def RV64 : HwMode<"+64bit">;
55def RV32 : HwMode<"-64bit">;
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000056
Shiva Chen39694252018-05-15 01:28:50 +000057def FeatureRelax
58 : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
59 "Enable Linker relaxation.">;
60
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000061//===----------------------------------------------------------------------===//
Alex Bradbury89718422017-10-19 21:37:38 +000062// Registers, calling conventions, instruction descriptions.
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000063//===----------------------------------------------------------------------===//
64
Alex Bradbury24d9b132016-11-01 23:40:28 +000065include "RISCVRegisterInfo.td"
Alex Bradbury89718422017-10-19 21:37:38 +000066include "RISCVCallingConv.td"
Alex Bradbury24d9b132016-11-01 23:40:28 +000067include "RISCVInstrInfo.td"
68
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000069//===----------------------------------------------------------------------===//
Ana Pazos9d6c5532018-10-04 21:50:54 +000070// Named operands for CSR instructions.
71//===----------------------------------------------------------------------===//
72
73include "RISCVSystemOperands.td"
74
75//===----------------------------------------------------------------------===//
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000076// RISC-V processors supported.
77//===----------------------------------------------------------------------===//
Alex Bradbury24d9b132016-11-01 23:40:28 +000078
79def : ProcessorModel<"generic-rv32", NoSchedModel, []>;
80
81def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
82
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000083//===----------------------------------------------------------------------===//
84// Define the RISC-V target.
85//===----------------------------------------------------------------------===//
86
Alex Bradbury89718422017-10-19 21:37:38 +000087def RISCVInstrInfo : InstrInfo {
Alex Bradburycc988412017-11-08 09:26:06 +000088 let guessInstructionProperties = 0;
Alex Bradbury89718422017-10-19 21:37:38 +000089}
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000090
Alex Bradbury1a427292017-08-08 14:32:35 +000091def RISCVAsmParser : AsmParser {
92 let ShouldEmitMatchRegisterAltName = 1;
Alex Bradbury7bc2a952017-12-07 10:46:23 +000093 let AllowDuplicateRegisterNames = 1;
Alex Bradbury1a427292017-08-08 14:32:35 +000094}
95
Ana Pazose3d24832018-01-12 02:27:00 +000096def RISCVAsmWriter : AsmWriter {
97 int PassSubtarget = 1;
98}
99
Alex Bradbury24d9b132016-11-01 23:40:28 +0000100def RISCV : Target {
101 let InstructionSet = RISCVInstrInfo;
Alex Bradbury1a427292017-08-08 14:32:35 +0000102 let AssemblyParsers = [RISCVAsmParser];
Ana Pazose3d24832018-01-12 02:27:00 +0000103 let AssemblyWriters = [RISCVAsmWriter];
Geoff Berryf8bf2ec2018-02-23 18:25:08 +0000104 let AllowRegisterRenaming = 1;
Alex Bradbury24d9b132016-11-01 23:40:28 +0000105}