]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h
Merge ^/head r317216 through r317280.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / PowerPC / MCTargetDesc / PPCMCTargetDesc.h
1 //===-- PPCMCTargetDesc.h - PowerPC Target Descriptions ---------*- C++ -*-===//
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 // This file provides PowerPC specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
15 #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
16
17 // GCC #defines PPC on Linux but we use it as our namespace name
18 #undef PPC
19
20 #include "llvm/Support/MathExtras.h"
21 #include <cstdint>
22
23 namespace llvm {
24
25 class MCAsmBackend;
26 class MCCodeEmitter;
27 class MCContext;
28 class MCInstrInfo;
29 class MCObjectWriter;
30 class MCRegisterInfo;
31 class MCTargetOptions;
32 class Target;
33 class Triple;
34 class StringRef;
35 class raw_pwrite_stream;
36
37 Target &getThePPC32Target();
38 Target &getThePPC64Target();
39 Target &getThePPC64LETarget();
40
41 MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
42                                       const MCRegisterInfo &MRI,
43                                       MCContext &Ctx);
44
45 MCAsmBackend *createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI,
46                                   const Triple &TT, StringRef CPU,
47                                   const MCTargetOptions &Options);
48
49 /// Construct an PPC ELF object writer.
50 MCObjectWriter *createPPCELFObjectWriter(raw_pwrite_stream &OS, bool Is64Bit,
51                                          bool IsLittleEndian, uint8_t OSABI);
52 /// Construct a PPC Mach-O object writer.
53 MCObjectWriter *createPPCMachObjectWriter(raw_pwrite_stream &OS, bool Is64Bit,
54                                           uint32_t CPUType,
55                                           uint32_t CPUSubtype);
56
57 /// Returns true iff Val consists of one contiguous run of 1s with any number of
58 /// 0s on either side.  The 1s are allowed to wrap from LSB to MSB, so
59 /// 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs.  0x0F0F0000 is not,
60 /// since all 1s are not contiguous.
61 static inline bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME) {
62   if (!Val)
63     return false;
64
65   if (isShiftedMask_32(Val)) {
66     // look for the first non-zero bit
67     MB = countLeadingZeros(Val);
68     // look for the first zero bit after the run of ones
69     ME = countLeadingZeros((Val - 1) ^ Val);
70     return true;
71   } else {
72     Val = ~Val; // invert mask
73     if (isShiftedMask_32(Val)) {
74       // effectively look for the first zero bit
75       ME = countLeadingZeros(Val) - 1;
76       // effectively look for the first one bit after the run of zeros
77       MB = countLeadingZeros((Val - 1) ^ Val) + 1;
78       return true;
79     }
80   }
81   // no run present
82   return false;
83 }
84
85 } // end namespace llvm
86
87 // Generated files will use "namespace PPC". To avoid symbol clash,
88 // undefine PPC here. PPC may be predefined on some hosts.
89 #undef PPC
90
91 // Defines symbolic names for PowerPC registers.  This defines a mapping from
92 // register name to register number.
93 //
94 #define GET_REGINFO_ENUM
95 #include "PPCGenRegisterInfo.inc"
96
97 // Defines symbolic names for the PowerPC instructions.
98 //
99 #define GET_INSTRINFO_ENUM
100 #include "PPCGenInstrInfo.inc"
101
102 #define GET_SUBTARGETINFO_ENUM
103 #include "PPCGenSubtargetInfo.inc"
104
105 #endif // LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H