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