Alex Bradbury | 24d9b13 | 2016-11-01 23:40:28 +0000 | [diff] [blame] | 1 | //===-- 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 | |
| 10 | include "llvm/Target/Target.td" |
| 11 | |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
| 13 | // RISC-V subtarget features and instruction predicates. |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Alex Bradbury | 8c345c5 | 2017-11-09 15:00:03 +0000 | [diff] [blame] | 16 | def FeatureStdExtM |
| 17 | : SubtargetFeature<"m", "HasStdExtM", "true", |
| 18 | "'M' (Integer Multiplication and Division)">; |
| 19 | def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">, |
Alex Bradbury | a47514c | 2017-11-09 14:46:30 +0000 | [diff] [blame] | 20 | AssemblerPredicate<"FeatureStdExtM">; |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 21 | |
Alex Bradbury | 8c345c5 | 2017-11-09 15:00:03 +0000 | [diff] [blame] | 22 | def FeatureStdExtA |
| 23 | : SubtargetFeature<"a", "HasStdExtA", "true", |
| 24 | "'A' (Atomic Instructions)">; |
| 25 | def HasStdExtA : Predicate<"Subtarget->hasStdExtA()">, |
| 26 | AssemblerPredicate<"FeatureStdExtA">; |
| 27 | |
Alex Bradbury | 0d6cf90 | 2017-12-07 10:26:05 +0000 | [diff] [blame] | 28 | def FeatureStdExtF |
| 29 | : SubtargetFeature<"f", "HasStdExtF", "true", |
| 30 | "'F' (Single-Precision Floating-Point)">; |
| 31 | def HasStdExtF : Predicate<"Subtarget->hasStdExtF()">, |
| 32 | AssemblerPredicate<"FeatureStdExtF">; |
| 33 | |
Alex Bradbury | 7bc2a95 | 2017-12-07 10:46:23 +0000 | [diff] [blame] | 34 | def FeatureStdExtD |
| 35 | : SubtargetFeature<"d", "HasStdExtD", "true", |
| 36 | "'D' (Double-Precision Floating-Point)", |
| 37 | [FeatureStdExtF]>; |
| 38 | def HasStdExtD : Predicate<"Subtarget->hasStdExtD()">, |
| 39 | AssemblerPredicate<"FeatureStdExtD">; |
| 40 | |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 41 | def FeatureStdExtC |
| 42 | : SubtargetFeature<"c", "HasStdExtC", "true", |
| 43 | "'C' (Compressed Instructions)">; |
| 44 | def HasStdExtC : Predicate<"Subtarget->hasStdExtC()">, |
| 45 | AssemblerPredicate<"FeatureStdExtC">; |
| 46 | |
| 47 | |
Alex Bradbury | 8c345c5 | 2017-11-09 15:00:03 +0000 | [diff] [blame] | 48 | def Feature64Bit |
| 49 | : SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">; |
Alex Bradbury | a6e6248 | 2017-12-07 10:53:48 +0000 | [diff] [blame] | 50 | def IsRV64 : Predicate<"Subtarget->is64Bit()">, |
| 51 | AssemblerPredicate<"Feature64Bit">; |
Alex Bradbury | 9ed84c8 | 2017-12-12 15:46:15 +0000 | [diff] [blame] | 52 | def IsRV32 : Predicate<"!Subtarget->is64Bit()">, |
| 53 | AssemblerPredicate<"!Feature64Bit">; |
Alex Bradbury | a47514c | 2017-11-09 14:46:30 +0000 | [diff] [blame] | 54 | |
| 55 | def RV64 : HwMode<"+64bit">; |
| 56 | def RV32 : HwMode<"-64bit">; |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 57 | |
| 58 | //===----------------------------------------------------------------------===// |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 59 | // Registers, calling conventions, instruction descriptions. |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 60 | //===----------------------------------------------------------------------===// |
| 61 | |
Alex Bradbury | 24d9b13 | 2016-11-01 23:40:28 +0000 | [diff] [blame] | 62 | include "RISCVRegisterInfo.td" |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 63 | include "RISCVCallingConv.td" |
Alex Bradbury | 24d9b13 | 2016-11-01 23:40:28 +0000 | [diff] [blame] | 64 | include "RISCVInstrInfo.td" |
| 65 | |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 66 | //===----------------------------------------------------------------------===// |
| 67 | // RISC-V processors supported. |
| 68 | //===----------------------------------------------------------------------===// |
Alex Bradbury | 24d9b13 | 2016-11-01 23:40:28 +0000 | [diff] [blame] | 69 | |
| 70 | def : ProcessorModel<"generic-rv32", NoSchedModel, []>; |
| 71 | |
| 72 | def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>; |
| 73 | |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 74 | //===----------------------------------------------------------------------===// |
| 75 | // Define the RISC-V target. |
| 76 | //===----------------------------------------------------------------------===// |
| 77 | |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 78 | def RISCVInstrInfo : InstrInfo { |
Alex Bradbury | cc98841 | 2017-11-08 09:26:06 +0000 | [diff] [blame] | 79 | let guessInstructionProperties = 0; |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 80 | } |
Alex Bradbury | ee7c7ec | 2017-10-19 14:29:03 +0000 | [diff] [blame] | 81 | |
Alex Bradbury | 1a42729 | 2017-08-08 14:32:35 +0000 | [diff] [blame] | 82 | def RISCVAsmParser : AsmParser { |
| 83 | let ShouldEmitMatchRegisterAltName = 1; |
Alex Bradbury | 7bc2a95 | 2017-12-07 10:46:23 +0000 | [diff] [blame] | 84 | let AllowDuplicateRegisterNames = 1; |
Alex Bradbury | 1a42729 | 2017-08-08 14:32:35 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Ana Pazos | e3d2483 | 2018-01-12 02:27:00 +0000 | [diff] [blame] | 87 | def RISCVAsmWriter : AsmWriter { |
| 88 | int PassSubtarget = 1; |
| 89 | } |
| 90 | |
Alex Bradbury | 24d9b13 | 2016-11-01 23:40:28 +0000 | [diff] [blame] | 91 | def RISCV : Target { |
| 92 | let InstructionSet = RISCVInstrInfo; |
Alex Bradbury | 1a42729 | 2017-08-08 14:32:35 +0000 | [diff] [blame] | 93 | let AssemblyParsers = [RISCVAsmParser]; |
Ana Pazos | e3d2483 | 2018-01-12 02:27:00 +0000 | [diff] [blame] | 94 | let AssemblyWriters = [RISCVAsmWriter]; |
Geoff Berry | f8bf2ec | 2018-02-23 18:25:08 +0000 | [diff] [blame] | 95 | let AllowRegisterRenaming = 1; |
Alex Bradbury | 24d9b13 | 2016-11-01 23:40:28 +0000 | [diff] [blame] | 96 | } |