Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 1 | //===-- Sparc.h - Top-level interface for Sparc representation --*- C++ -*-===// |
| 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 |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains the entry points for global functions defined in the LLVM |
| 10 | // Sparc back-end. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_SPARC_SPARC_H |
| 15 | #define LLVM_LIB_TARGET_SPARC_SPARC_H |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 16 | |
Evan Cheng | bc153d4 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/SparcMCTargetDesc.h" |
Torok Edwin | 56d0659 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 18 | #include "llvm/Support/ErrorHandling.h" |
Bill Wendling | 026e5d7 | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachine.h" |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | class FunctionPass; |
Dan Gohman | 2c836cf | 2008-10-03 16:55:19 +0000 | [diff] [blame] | 23 | class SparcTargetMachine; |
David Greene | a31f96c | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 24 | class formatted_raw_ostream; |
Venkatraman Govindaraju | bf683fd | 2013-12-26 01:49:59 +0000 | [diff] [blame] | 25 | class AsmPrinter; |
| 26 | class MCInst; |
| 27 | class MachineInstr; |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 28 | |
Dan Gohman | 2c836cf | 2008-10-03 16:55:19 +0000 | [diff] [blame] | 29 | FunctionPass *createSparcISelDag(SparcTargetMachine &TM); |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 30 | FunctionPass *createSparcDelaySlotFillerPass(); |
Daniel Dunbar | 67038c1 | 2009-07-18 23:03:22 +0000 | [diff] [blame] | 31 | |
Venkatraman Govindaraju | bf683fd | 2013-12-26 01:49:59 +0000 | [diff] [blame] | 32 | void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, |
| 33 | MCInst &OutMI, |
| 34 | AsmPrinter &AP); |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 35 | } // end namespace llvm; |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 36 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 37 | namespace llvm { |
| 38 | // Enums corresponding to Sparc condition codes, both icc's and fcc's. These |
| 39 | // values must be kept in sync with the ones in the .td file. |
| 40 | namespace SPCC { |
| 41 | enum CondCodes { |
Venkatraman Govindaraju | 2286874 | 2014-03-01 20:08:48 +0000 | [diff] [blame] | 42 | ICC_A = 8 , // Always |
| 43 | ICC_N = 0 , // Never |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 44 | ICC_NE = 9 , // Not Equal |
| 45 | ICC_E = 1 , // Equal |
| 46 | ICC_G = 10 , // Greater |
| 47 | ICC_LE = 2 , // Less or Equal |
| 48 | ICC_GE = 11 , // Greater or Equal |
| 49 | ICC_L = 3 , // Less |
| 50 | ICC_GU = 12 , // Greater Unsigned |
| 51 | ICC_LEU = 4 , // Less or Equal Unsigned |
| 52 | ICC_CC = 13 , // Carry Clear/Great or Equal Unsigned |
| 53 | ICC_CS = 5 , // Carry Set/Less Unsigned |
| 54 | ICC_POS = 14 , // Positive |
| 55 | ICC_NEG = 6 , // Negative |
| 56 | ICC_VC = 15 , // Overflow Clear |
| 57 | ICC_VS = 7 , // Overflow Set |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 58 | |
Venkatraman Govindaraju | 2286874 | 2014-03-01 20:08:48 +0000 | [diff] [blame] | 59 | FCC_A = 8+16, // Always |
| 60 | FCC_N = 0+16, // Never |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 61 | FCC_U = 7+16, // Unordered |
| 62 | FCC_G = 6+16, // Greater |
| 63 | FCC_UG = 5+16, // Unordered or Greater |
| 64 | FCC_L = 4+16, // Less |
| 65 | FCC_UL = 3+16, // Unordered or Less |
| 66 | FCC_LG = 2+16, // Less or Greater |
| 67 | FCC_NE = 1+16, // Not Equal |
| 68 | FCC_E = 9+16, // Equal |
| 69 | FCC_UE = 10+16, // Unordered or Equal |
| 70 | FCC_GE = 11+16, // Greater or Equal |
| 71 | FCC_UGE = 12+16, // Unordered or Greater or Equal |
| 72 | FCC_LE = 13+16, // Less or Equal |
| 73 | FCC_ULE = 14+16, // Unordered or Less or Equal |
Chris Dewhurst | 52adb57 | 2016-03-09 18:20:21 +0000 | [diff] [blame] | 74 | FCC_O = 15+16, // Ordered |
Fangrui Song | f78650a | 2018-07-30 19:41:25 +0000 | [diff] [blame] | 75 | |
Chris Dewhurst | 52adb57 | 2016-03-09 18:20:21 +0000 | [diff] [blame] | 76 | CPCC_A = 8+32, // Always |
| 77 | CPCC_N = 0+32, // Never |
| 78 | CPCC_3 = 7+32, |
| 79 | CPCC_2 = 6+32, |
| 80 | CPCC_23 = 5+32, |
| 81 | CPCC_1 = 4+32, |
| 82 | CPCC_13 = 3+32, |
| 83 | CPCC_12 = 2+32, |
| 84 | CPCC_123 = 1+32, |
| 85 | CPCC_0 = 9+32, |
| 86 | CPCC_03 = 10+32, |
| 87 | CPCC_02 = 11+32, |
| 88 | CPCC_023 = 12+32, |
| 89 | CPCC_01 = 13+32, |
| 90 | CPCC_013 = 14+32, |
| 91 | CPCC_012 = 15+32 |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 92 | }; |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 93 | } |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 94 | |
Chris Lattner | 71f5513 | 2006-11-03 01:11:05 +0000 | [diff] [blame] | 95 | inline static const char *SPARCCondCodeToString(SPCC::CondCodes CC) { |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 96 | switch (CC) { |
Venkatraman Govindaraju | 2286874 | 2014-03-01 20:08:48 +0000 | [diff] [blame] | 97 | case SPCC::ICC_A: return "a"; |
| 98 | case SPCC::ICC_N: return "n"; |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 99 | case SPCC::ICC_NE: return "ne"; |
| 100 | case SPCC::ICC_E: return "e"; |
| 101 | case SPCC::ICC_G: return "g"; |
| 102 | case SPCC::ICC_LE: return "le"; |
| 103 | case SPCC::ICC_GE: return "ge"; |
| 104 | case SPCC::ICC_L: return "l"; |
| 105 | case SPCC::ICC_GU: return "gu"; |
| 106 | case SPCC::ICC_LEU: return "leu"; |
| 107 | case SPCC::ICC_CC: return "cc"; |
| 108 | case SPCC::ICC_CS: return "cs"; |
| 109 | case SPCC::ICC_POS: return "pos"; |
| 110 | case SPCC::ICC_NEG: return "neg"; |
| 111 | case SPCC::ICC_VC: return "vc"; |
| 112 | case SPCC::ICC_VS: return "vs"; |
Venkatraman Govindaraju | 2286874 | 2014-03-01 20:08:48 +0000 | [diff] [blame] | 113 | case SPCC::FCC_A: return "a"; |
| 114 | case SPCC::FCC_N: return "n"; |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 115 | case SPCC::FCC_U: return "u"; |
| 116 | case SPCC::FCC_G: return "g"; |
| 117 | case SPCC::FCC_UG: return "ug"; |
| 118 | case SPCC::FCC_L: return "l"; |
| 119 | case SPCC::FCC_UL: return "ul"; |
| 120 | case SPCC::FCC_LG: return "lg"; |
| 121 | case SPCC::FCC_NE: return "ne"; |
| 122 | case SPCC::FCC_E: return "e"; |
| 123 | case SPCC::FCC_UE: return "ue"; |
| 124 | case SPCC::FCC_GE: return "ge"; |
| 125 | case SPCC::FCC_UGE: return "uge"; |
| 126 | case SPCC::FCC_LE: return "le"; |
| 127 | case SPCC::FCC_ULE: return "ule"; |
| 128 | case SPCC::FCC_O: return "o"; |
Chris Dewhurst | 52adb57 | 2016-03-09 18:20:21 +0000 | [diff] [blame] | 129 | case SPCC::CPCC_A: return "a"; |
| 130 | case SPCC::CPCC_N: return "n"; |
| 131 | case SPCC::CPCC_3: return "3"; |
| 132 | case SPCC::CPCC_2: return "2"; |
| 133 | case SPCC::CPCC_23: return "23"; |
| 134 | case SPCC::CPCC_1: return "1"; |
| 135 | case SPCC::CPCC_13: return "13"; |
| 136 | case SPCC::CPCC_12: return "12"; |
| 137 | case SPCC::CPCC_123: return "123"; |
| 138 | case SPCC::CPCC_0: return "0"; |
| 139 | case SPCC::CPCC_03: return "03"; |
| 140 | case SPCC::CPCC_02: return "02"; |
| 141 | case SPCC::CPCC_023: return "023"; |
| 142 | case SPCC::CPCC_01: return "01"; |
| 143 | case SPCC::CPCC_013: return "013"; |
| 144 | case SPCC::CPCC_012: return "012"; |
Benjamin Kramer | 233149c | 2012-01-10 20:47:20 +0000 | [diff] [blame] | 145 | } |
| 146 | llvm_unreachable("Invalid cond code"); |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 147 | } |
Venkatraman Govindaraju | 1116868 | 2013-11-24 20:23:25 +0000 | [diff] [blame] | 148 | |
| 149 | inline static unsigned HI22(int64_t imm) { |
| 150 | return (unsigned)((imm >> 10) & ((1 << 22)-1)); |
| 151 | } |
| 152 | |
| 153 | inline static unsigned LO10(int64_t imm) { |
| 154 | return (unsigned)(imm & 0x3FF); |
| 155 | } |
| 156 | |
| 157 | inline static unsigned HIX22(int64_t imm) { |
| 158 | return HI22(~imm); |
| 159 | } |
| 160 | |
| 161 | inline static unsigned LOX10(int64_t imm) { |
| 162 | return ~LO10(~imm); |
| 163 | } |
| 164 | |
Chris Lattner | 158e1f5 | 2006-02-05 05:50:24 +0000 | [diff] [blame] | 165 | } // end namespace llvm |
| 166 | #endif |