| Chris Lattner | 12e9730 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 1 | //===-- PPC.h - Top-level interface for PowerPC Target ----------*- C++ -*-===// | 
| Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 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 | 
| Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 6 | // | 
| Misha Brukman | e05203f | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 7 | //===----------------------------------------------------------------------===// | 
|  | 8 | // | 
|  | 9 | // This file contains the entry points for global functions defined in the LLVM | 
|  | 10 | // PowerPC back-end. | 
|  | 11 | // | 
|  | 12 | //===----------------------------------------------------------------------===// | 
|  | 13 |  | 
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_POWERPC_PPC_H | 
|  | 15 | #define LLVM_LIB_TARGET_POWERPC_PPC_H | 
| Misha Brukman | e05203f | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 16 |  | 
| Hiroshi Inoue | 5102028 | 2017-06-27 04:52:17 +0000 | [diff] [blame] | 17 | #include "llvm/Support/CodeGen.h" | 
| Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 18 |  | 
| Chris Lattner | 6be7260 | 2006-11-04 05:27:39 +0000 | [diff] [blame] | 19 | // GCC #defines PPC on Linux but we use it as our namespace name | 
|  | 20 | #undef PPC | 
|  | 21 |  | 
| Misha Brukman | e05203f | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 22 | namespace llvm { | 
| Chris Lattner | 6be7260 | 2006-11-04 05:27:39 +0000 | [diff] [blame] | 23 | class PPCTargetMachine; | 
| Hal Finkel | 174e590 | 2014-03-25 23:29:21 +0000 | [diff] [blame] | 24 | class PassRegistry; | 
| Chris Lattner | 6be7260 | 2006-11-04 05:27:39 +0000 | [diff] [blame] | 25 | class FunctionPass; | 
| Chris Lattner | 5c1b0cd | 2010-11-14 21:12:33 +0000 | [diff] [blame] | 26 | class MachineInstr; | 
| Tim Shen | cee7536 | 2017-09-22 18:30:02 +0000 | [diff] [blame] | 27 | class MachineOperand; | 
| Chris Lattner | 5c1b0cd | 2010-11-14 21:12:33 +0000 | [diff] [blame] | 28 | class AsmPrinter; | 
| Chris Lattner | 9ec375c | 2010-11-15 04:16:32 +0000 | [diff] [blame] | 29 | class MCInst; | 
| Tim Shen | cee7536 | 2017-09-22 18:30:02 +0000 | [diff] [blame] | 30 | class MCOperand; | 
| Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 31 |  | 
| Eric Christopher | b16eacf | 2017-06-29 23:28:45 +0000 | [diff] [blame] | 32 | FunctionPass *createPPCCTRLoops(); | 
| Hal Finkel | 8ca3884 | 2013-05-20 16:08:17 +0000 | [diff] [blame] | 33 | #ifndef NDEBUG | 
|  | 34 | FunctionPass *createPPCCTRLoopsVerify(); | 
|  | 35 | #endif | 
| Hal Finkel | c9dd020 | 2015-02-05 18:43:00 +0000 | [diff] [blame] | 36 | FunctionPass *createPPCLoopPreIncPrepPass(PPCTargetMachine &TM); | 
| Hal Finkel | 8340de1 | 2015-05-18 06:25:59 +0000 | [diff] [blame] | 37 | FunctionPass *createPPCTOCRegDepsPass(); | 
| Hal Finkel | b5aa7e5 | 2013-04-08 16:24:03 +0000 | [diff] [blame] | 38 | FunctionPass *createPPCEarlyReturnPass(); | 
| Hal Finkel | 27774d9 | 2014-03-13 07:58:58 +0000 | [diff] [blame] | 39 | FunctionPass *createPPCVSXCopyPass(); | 
| Hal Finkel | 174e590 | 2014-03-25 23:29:21 +0000 | [diff] [blame] | 40 | FunctionPass *createPPCVSXFMAMutatePass(); | 
| Bill Schmidt | fe723b9 | 2015-04-27 19:57:34 +0000 | [diff] [blame] | 41 | FunctionPass *createPPCVSXSwapRemovalPass(); | 
| Nemanja Ivanovic | 6f590bf | 2017-12-13 14:47:35 +0000 | [diff] [blame] | 42 | FunctionPass *createPPCReduceCRLogicalsPass(); | 
| Bill Schmidt | 34af5e1 | 2015-11-10 21:38:26 +0000 | [diff] [blame] | 43 | FunctionPass *createPPCMIPeepholePass(); | 
| Chris Lattner | dd6df84 | 2010-11-15 03:13:19 +0000 | [diff] [blame] | 44 | FunctionPass *createPPCBranchSelectionPass(); | 
| Lei Huang | 34e6621 | 2017-09-12 18:39:11 +0000 | [diff] [blame] | 45 | FunctionPass *createPPCBranchCoalescingPass(); | 
| Hal Finkel | fc35391 | 2016-03-31 20:39:41 +0000 | [diff] [blame] | 46 | FunctionPass *createPPCQPXLoadSplatPass(); | 
| Hiroshi Inoue | 5102028 | 2017-06-27 04:52:17 +0000 | [diff] [blame] | 47 | FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOpt::Level OL); | 
| Bill Schmidt | 82f1c77 | 2015-02-10 19:09:05 +0000 | [diff] [blame] | 48 | FunctionPass *createPPCTLSDynamicCallPass(); | 
| Eric Christopher | 9fd267c | 2017-03-31 02:16:54 +0000 | [diff] [blame] | 49 | FunctionPass *createPPCBoolRetToIntPass(); | 
| Tony Jiang | 8e8c444 | 2017-01-16 20:12:26 +0000 | [diff] [blame] | 50 | FunctionPass *createPPCExpandISELPass(); | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 51 | FunctionPass *createPPCPreEmitPeepholePass(); | 
| Chris Lattner | dd6df84 | 2010-11-15 03:13:19 +0000 | [diff] [blame] | 52 | void LowerPPCMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, | 
| Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame] | 53 | AsmPrinter &AP, bool isDarwin); | 
| Tim Shen | cee7536 | 2017-09-22 18:30:02 +0000 | [diff] [blame] | 54 | bool LowerPPCMachineOperandToMCOperand(const MachineOperand &MO, | 
|  | 55 | MCOperand &OutMO, AsmPrinter &AP, | 
|  | 56 | bool isDarwin); | 
| Hal Finkel | 4e5ca9e | 2013-01-25 23:05:59 +0000 | [diff] [blame] | 57 |  | 
| Kang Zhang | 2446f84 | 2019-04-12 09:59:40 +0000 | [diff] [blame] | 58 | void initializePPCCTRLoopsPass(PassRegistry&); | 
|  | 59 | #ifndef NDEBUG | 
|  | 60 | void initializePPCCTRLoopsVerifyPass(PassRegistry&); | 
|  | 61 | #endif | 
|  | 62 | void initializePPCLoopPreIncPrepPass(PassRegistry&); | 
|  | 63 | void initializePPCTOCRegDepsPass(PassRegistry&); | 
|  | 64 | void initializePPCEarlyReturnPass(PassRegistry&); | 
|  | 65 | void initializePPCVSXCopyPass(PassRegistry&); | 
| Hal Finkel | 174e590 | 2014-03-25 23:29:21 +0000 | [diff] [blame] | 66 | void initializePPCVSXFMAMutatePass(PassRegistry&); | 
| Kang Zhang | 2446f84 | 2019-04-12 09:59:40 +0000 | [diff] [blame] | 67 | void initializePPCVSXSwapRemovalPass(PassRegistry&); | 
|  | 68 | void initializePPCReduceCRLogicalsPass(PassRegistry&); | 
|  | 69 | void initializePPCBSelPass(PassRegistry&); | 
|  | 70 | void initializePPCBranchCoalescingPass(PassRegistry&); | 
|  | 71 | void initializePPCQPXLoadSplatPass(PassRegistry&); | 
| Kit Barton | a1c712f | 2015-12-07 20:50:29 +0000 | [diff] [blame] | 72 | void initializePPCBoolRetToIntPass(PassRegistry&); | 
| Tony Jiang | 8e8c444 | 2017-01-16 20:12:26 +0000 | [diff] [blame] | 73 | void initializePPCExpandISELPass(PassRegistry &); | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 74 | void initializePPCPreEmitPeepholePass(PassRegistry &); | 
| Hiroshi Inoue | 6989caa | 2017-06-29 14:13:38 +0000 | [diff] [blame] | 75 | void initializePPCTLSDynamicCallPass(PassRegistry &); | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 76 | void initializePPCMIPeepholePass(PassRegistry&); | 
| Kang Zhang | 2446f84 | 2019-04-12 09:59:40 +0000 | [diff] [blame] | 77 |  | 
| Hal Finkel | 174e590 | 2014-03-25 23:29:21 +0000 | [diff] [blame] | 78 | extern char &PPCVSXFMAMutateID; | 
|  | 79 |  | 
| Chris Lattner | df8e17d | 2010-11-14 23:42:06 +0000 | [diff] [blame] | 80 | namespace PPCII { | 
| Fangrui Song | f78650a | 2018-07-30 19:41:25 +0000 | [diff] [blame] | 81 |  | 
| Chris Lattner | df8e17d | 2010-11-14 23:42:06 +0000 | [diff] [blame] | 82 | /// Target Operand Flag enum. | 
|  | 83 | enum TOF { | 
|  | 84 | //===------------------------------------------------------------------===// | 
|  | 85 | // PPC Specific MachineOperand flags. | 
|  | 86 | MO_NO_FLAG, | 
| Rafael Espindola | a99ccfc | 2016-06-29 14:59:50 +0000 | [diff] [blame] | 87 |  | 
|  | 88 | /// On a symbol operand "FOO", this indicates that the reference is actually | 
|  | 89 | /// to "FOO@plt".  This is used for calls and jumps to external functions on | 
| Hal Finkel | 3ee2af7 | 2014-07-18 23:29:49 +0000 | [diff] [blame] | 90 | /// for PIC calls on Linux and ELF systems. | 
| Rafael Espindola | a99ccfc | 2016-06-29 14:59:50 +0000 | [diff] [blame] | 91 | MO_PLT = 1, | 
|  | 92 |  | 
| Chris Lattner | dd6df84 | 2010-11-15 03:13:19 +0000 | [diff] [blame] | 93 | /// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to | 
|  | 94 | /// the function's picbase, e.g. lo16(symbol-picbase). | 
| Bill Schmidt | 3822ef2 | 2013-02-21 00:05:29 +0000 | [diff] [blame] | 95 | MO_PIC_FLAG = 2, | 
| Chris Lattner | dd6df84 | 2010-11-15 03:13:19 +0000 | [diff] [blame] | 96 |  | 
|  | 97 | /// MO_NLP_FLAG - If this bit is set, the symbol reference is actually to | 
|  | 98 | /// the non_lazy_ptr for the global, e.g. lo16(symbol$non_lazy_ptr-picbase). | 
| Bill Schmidt | 3822ef2 | 2013-02-21 00:05:29 +0000 | [diff] [blame] | 99 | MO_NLP_FLAG = 4, | 
| Rafael Espindola | a99ccfc | 2016-06-29 14:59:50 +0000 | [diff] [blame] | 100 |  | 
| Chris Lattner | dd6df84 | 2010-11-15 03:13:19 +0000 | [diff] [blame] | 101 | /// MO_NLP_HIDDEN_FLAG - If this bit is set, the symbol reference is to a | 
|  | 102 | /// symbol with hidden visibility.  This causes a different kind of | 
|  | 103 | /// non-lazy-pointer to be generated. | 
| Bill Schmidt | 3822ef2 | 2013-02-21 00:05:29 +0000 | [diff] [blame] | 104 | MO_NLP_HIDDEN_FLAG = 8, | 
| Roman Divacky | e3f15c98 | 2012-06-04 17:36:38 +0000 | [diff] [blame] | 105 |  | 
|  | 106 | /// The next are not flags but distinct values. | 
| Bill Schmidt | 3822ef2 | 2013-02-21 00:05:29 +0000 | [diff] [blame] | 107 | MO_ACCESS_MASK = 0xf0, | 
| Roman Divacky | e3f15c98 | 2012-06-04 17:36:38 +0000 | [diff] [blame] | 108 |  | 
| Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 109 | /// MO_LO, MO_HA - lo16(symbol) and ha16(symbol) | 
|  | 110 | MO_LO = 1 << 4, | 
|  | 111 | MO_HA = 2 << 4, | 
| Roman Divacky | e3f15c98 | 2012-06-04 17:36:38 +0000 | [diff] [blame] | 112 |  | 
| Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 113 | MO_TPREL_LO = 4 << 4, | 
|  | 114 | MO_TPREL_HA = 3 << 4, | 
| Bill Schmidt | 3822ef2 | 2013-02-21 00:05:29 +0000 | [diff] [blame] | 115 |  | 
|  | 116 | /// These values identify relocations on immediates folded | 
|  | 117 | /// into memory operations. | 
| Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 118 | MO_DTPREL_LO = 5 << 4, | 
| Rafael Espindola | a99ccfc | 2016-06-29 14:59:50 +0000 | [diff] [blame] | 119 | MO_TLSLD_LO = 6 << 4, | 
|  | 120 | MO_TOC_LO = 7 << 4, | 
| Ulrich Weigand | 5b42759 | 2013-07-05 12:22:36 +0000 | [diff] [blame] | 121 |  | 
|  | 122 | // Symbol for VK_PPC_TLS fixup attached to an ADD instruction | 
| Rafael Espindola | a99ccfc | 2016-06-29 14:59:50 +0000 | [diff] [blame] | 123 | MO_TLS = 8 << 4 | 
| Chris Lattner | df8e17d | 2010-11-14 23:42:06 +0000 | [diff] [blame] | 124 | }; | 
|  | 125 | } // end namespace PPCII | 
| Fangrui Song | f78650a | 2018-07-30 19:41:25 +0000 | [diff] [blame] | 126 |  | 
| Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 127 | } // end namespace llvm; | 
| Misha Brukman | e05203f | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 128 |  | 
| Misha Brukman | e05203f | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 129 | #endif |