blob: 3e80d745b827c0d88f64b9240be452503d069577 [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
58//===----------------------------------------------------------------------===//
Alex Bradbury89718422017-10-19 21:37:38 +000059// Registers, calling conventions, instruction descriptions.
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000060//===----------------------------------------------------------------------===//
61
Alex Bradbury24d9b132016-11-01 23:40:28 +000062include "RISCVRegisterInfo.td"
Alex Bradbury89718422017-10-19 21:37:38 +000063include "RISCVCallingConv.td"
Alex Bradbury24d9b132016-11-01 23:40:28 +000064include "RISCVInstrInfo.td"
65
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000066//===----------------------------------------------------------------------===//
67// RISC-V processors supported.
68//===----------------------------------------------------------------------===//
Alex Bradbury24d9b132016-11-01 23:40:28 +000069
70def : ProcessorModel<"generic-rv32", NoSchedModel, []>;
71
72def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
73
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000074//===----------------------------------------------------------------------===//
75// Define the RISC-V target.
76//===----------------------------------------------------------------------===//
77
Alex Bradbury89718422017-10-19 21:37:38 +000078def RISCVInstrInfo : InstrInfo {
Alex Bradburycc988412017-11-08 09:26:06 +000079 let guessInstructionProperties = 0;
Alex Bradbury89718422017-10-19 21:37:38 +000080}
Alex Bradburyee7c7ec2017-10-19 14:29:03 +000081
Alex Bradbury1a427292017-08-08 14:32:35 +000082def RISCVAsmParser : AsmParser {
83 let ShouldEmitMatchRegisterAltName = 1;
Alex Bradbury7bc2a952017-12-07 10:46:23 +000084 let AllowDuplicateRegisterNames = 1;
Alex Bradbury1a427292017-08-08 14:32:35 +000085}
86
Ana Pazose3d24832018-01-12 02:27:00 +000087def RISCVAsmWriter : AsmWriter {
88 int PassSubtarget = 1;
89}
90
Alex Bradbury24d9b132016-11-01 23:40:28 +000091def RISCV : Target {
92 let InstructionSet = RISCVInstrInfo;
Alex Bradbury1a427292017-08-08 14:32:35 +000093 let AssemblyParsers = [RISCVAsmParser];
Ana Pazose3d24832018-01-12 02:27:00 +000094 let AssemblyWriters = [RISCVAsmWriter];
Geoff Berryf8bf2ec2018-02-23 18:25:08 +000095 let AllowRegisterRenaming = 1;
Alex Bradbury24d9b132016-11-01 23:40:28 +000096}