LLVM  6.0.0svn
PPCMCTargetDesc.h
Go to the documentation of this file.
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 
21 #include <cstdint>
22 #include <memory>
23 
24 namespace llvm {
25 
26 class MCAsmBackend;
27 class MCCodeEmitter;
28 class MCContext;
29 class MCInstrInfo;
30 class MCObjectWriter;
31 class MCRegisterInfo;
32 class MCTargetOptions;
33 class Target;
34 class Triple;
35 class StringRef;
36 class raw_pwrite_stream;
37 
38 Target &getThePPC32Target();
39 Target &getThePPC64Target();
40 Target &getThePPC64LETarget();
41 
42 MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
43  const MCRegisterInfo &MRI,
44  MCContext &Ctx);
45 
46 MCAsmBackend *createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI,
47  const Triple &TT, StringRef CPU,
48  const MCTargetOptions &Options);
49 
50 /// Construct an PPC ELF object writer.
51 std::unique_ptr<MCObjectWriter> createPPCELFObjectWriter(raw_pwrite_stream &OS,
52  bool Is64Bit,
53  bool IsLittleEndian,
54  uint8_t OSABI);
55 /// Construct a PPC Mach-O object writer.
56 std::unique_ptr<MCObjectWriter> createPPCMachObjectWriter(raw_pwrite_stream &OS,
57  bool Is64Bit,
59  uint32_t CPUSubtype);
60 
61 /// Returns true iff Val consists of one contiguous run of 1s with any number of
62 /// 0s on either side. The 1s are allowed to wrap from LSB to MSB, so
63 /// 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is not,
64 /// since all 1s are not contiguous.
65 static inline bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME) {
66  if (!Val)
67  return false;
68 
69  if (isShiftedMask_32(Val)) {
70  // look for the first non-zero bit
71  MB = countLeadingZeros(Val);
72  // look for the first zero bit after the run of ones
73  ME = countLeadingZeros((Val - 1) ^ Val);
74  return true;
75  } else {
76  Val = ~Val; // invert mask
77  if (isShiftedMask_32(Val)) {
78  // effectively look for the first zero bit
79  ME = countLeadingZeros(Val) - 1;
80  // effectively look for the first one bit after the run of zeros
81  MB = countLeadingZeros((Val - 1) ^ Val) + 1;
82  return true;
83  }
84  }
85  // no run present
86  return false;
87 }
88 
89 } // end namespace llvm
90 
91 // Generated files will use "namespace PPC". To avoid symbol clash,
92 // undefine PPC here. PPC may be predefined on some hosts.
93 #undef PPC
94 
95 // Defines symbolic names for PowerPC registers. This defines a mapping from
96 // register name to register number.
97 //
98 #define GET_REGINFO_ENUM
99 #include "PPCGenRegisterInfo.inc"
100 
101 // Defines symbolic names for the PowerPC instructions.
102 //
103 #define GET_INSTRINFO_ENUM
104 #include "PPCGenInstrInfo.inc"
105 
106 #define GET_SUBTARGETINFO_ENUM
107 #include "PPCGenSubtargetInfo.inc"
108 
109 #endif // LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
MCAsmBackend * createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, const MCTargetOptions &Options)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Target & getThePPC32Target()
std::size_t countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0&#39;s from the most significant bit to the least stopping at the first 1...
Definition: MathExtras.h:181
std::unique_ptr< MCObjectWriter > createPPCMachObjectWriter(raw_pwrite_stream &OS, bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct a PPC Mach-O object writer.
Target & getThePPC64Target()
unsigned const MachineRegisterInfo * MRI
std::unique_ptr< MCObjectWriter > createPPCELFObjectWriter(raw_pwrite_stream &OS, bool Is64Bit, bool IsLittleEndian, uint8_t OSABI)
Construct an PPC ELF object writer.
Target & getThePPC64LETarget()
static bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME)
Returns true iff Val consists of one contiguous run of 1s with any number of 0s on either side...
constexpr bool isShiftedMask_32(uint32_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (32 bit ver...
Definition: MathExtras.h:409
MCCodeEmitter * createPPCMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)