blob: 0e86e2bc5e98c78c20425a7e51f4fb58376de8c8 [file] [log] [blame]
Alex Bradbury24d9b132016-11-01 23:40:28 +00001//===-- RISCV.td - Describe the RISCV Target Machine -------*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10include "llvm/Target/Target.td"
11
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000012//===----------------------------------------------------------------------===//
13// RISC-V subtarget features and instruction predicates.
14//===----------------------------------------------------------------------===//
15
Alex Bradbury8c345c52017-11-09 15:00:03 +000016def FeatureStdExtM
17 : SubtargetFeature<"m", "HasStdExtM", "true",
18 "'M' (Integer Multiplication and Division)">;
19def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
Alex Bradburya47514c2017-11-09 14:46:30 +000020 AssemblerPredicate<"FeatureStdExtM">;
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000021
Alex Bradbury8c345c52017-11-09 15:00:03 +000022def FeatureStdExtA
23 : SubtargetFeature<"a", "HasStdExtA", "true",
24 "'A' (Atomic Instructions)">;
25def HasStdExtA : Predicate<"Subtarget->hasStdExtA()">,
26 AssemblerPredicate<"FeatureStdExtA">;
27
Alex Bradbury0d6cf902017-12-07 10:26:05 +000028def FeatureStdExtF
29 : SubtargetFeature<"f", "HasStdExtF", "true",
30 "'F' (Single-Precision Floating-Point)">;
31def HasStdExtF : Predicate<"Subtarget->hasStdExtF()">,
32 AssemblerPredicate<"FeatureStdExtF">;
33
Alex Bradbury7bc2a952017-12-07 10:46:23 +000034def FeatureStdExtD
35 : SubtargetFeature<"d", "HasStdExtD", "true",
36 "'D' (Double-Precision Floating-Point)",
37 [FeatureStdExtF]>;
38def HasStdExtD : Predicate<"Subtarget->hasStdExtD()">,
39 AssemblerPredicate<"FeatureStdExtD">;
40
Alex Bradbury9f6aec42017-12-07 12:50:32 +000041def FeatureStdExtC
42 : SubtargetFeature<"c", "HasStdExtC", "true",
43 "'C' (Compressed Instructions)">;
44def HasStdExtC : Predicate<"Subtarget->hasStdExtC()">,
45 AssemblerPredicate<"FeatureStdExtC">;
46
47
Alex Bradbury8c345c52017-11-09 15:00:03 +000048def Feature64Bit
49 : SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">;
Alex Bradburya6e62482017-12-07 10:53:48 +000050def IsRV64 : Predicate<"Subtarget->is64Bit()">,
51 AssemblerPredicate<"Feature64Bit">;
Alex Bradbury9ed84c82017-12-12 15:46:15 +000052def IsRV32 : Predicate<"!Subtarget->is64Bit()">,
53 AssemblerPredicate<"!Feature64Bit">;
Alex Bradburya47514c2017-11-09 14:46:30 +000054
55def RV64 : HwMode<"+64bit">;
56def RV32 : HwMode<"-64bit">;
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000057
Shiva Chen39694252018-05-15 01:28:50 +000058def FeatureRelax
59 : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
60 "Enable Linker relaxation.">;
61
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000062//===----------------------------------------------------------------------===//
Alex Bradbury89718422017-10-19 21:37:38 +000063// Registers, calling conventions, instruction descriptions.
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000064//===----------------------------------------------------------------------===//
65
Alex Bradbury24d9b132016-11-01 23:40:28 +000066include "RISCVRegisterInfo.td"
Alex Bradbury89718422017-10-19 21:37:38 +000067include "RISCVCallingConv.td"
Alex Bradbury24d9b132016-11-01 23:40:28 +000068include "RISCVInstrInfo.td"
69
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000070//===----------------------------------------------------------------------===//
Ana Pazos9d6c5532018-10-04 21:50:54 +000071// Named operands for CSR instructions.
72//===----------------------------------------------------------------------===//
73
74include "RISCVSystemOperands.td"
75
76//===----------------------------------------------------------------------===//
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000077// RISC-V processors supported.
78//===----------------------------------------------------------------------===//
Alex Bradbury24d9b132016-11-01 23:40:28 +000079
80def : ProcessorModel<"generic-rv32", NoSchedModel, []>;
81
82def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
83
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000084//===----------------------------------------------------------------------===//
85// Define the RISC-V target.
86//===----------------------------------------------------------------------===//
87
Alex Bradbury89718422017-10-19 21:37:38 +000088def RISCVInstrInfo : InstrInfo {
Alex Bradburycc988412017-11-08 09:26:06 +000089 let guessInstructionProperties = 0;
Alex Bradbury89718422017-10-19 21:37:38 +000090}
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000091
Alex Bradbury1a427292017-08-08 14:32:35 +000092def RISCVAsmParser : AsmParser {
93 let ShouldEmitMatchRegisterAltName = 1;
Alex Bradbury7bc2a952017-12-07 10:46:23 +000094 let AllowDuplicateRegisterNames = 1;
Alex Bradbury1a427292017-08-08 14:32:35 +000095}
96
Ana Pazose3d24832018-01-12 02:27:00 +000097def RISCVAsmWriter : AsmWriter {
98 int PassSubtarget = 1;
99}
100
Alex Bradbury24d9b132016-11-01 23:40:28 +0000101def RISCV : Target {
102 let InstructionSet = RISCVInstrInfo;
Alex Bradbury1a427292017-08-08 14:32:35 +0000103 let AssemblyParsers = [RISCVAsmParser];
Ana Pazose3d24832018-01-12 02:27:00 +0000104 let AssemblyWriters = [RISCVAsmWriter];
Geoff Berryf8bf2ec2018-02-23 18:25:08 +0000105 let AllowRegisterRenaming = 1;
Alex Bradbury24d9b132016-11-01 23:40:28 +0000106}