1 //===-- PPCMCTargetDesc.h - PowerPC Target Descriptions ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides PowerPC specific target descriptions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
15 #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
17 // GCC #defines PPC on Linux but we use it as our namespace name
20 #include "llvm/Support/MathExtras.h"
31 class MCTargetOptions;
35 class raw_pwrite_stream;
37 Target &getThePPC32Target();
38 Target &getThePPC64Target();
39 Target &getThePPC64LETarget();
41 MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
42 const MCRegisterInfo &MRI,
45 MCAsmBackend *createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI,
46 const Triple &TT, StringRef CPU,
47 const MCTargetOptions &Options);
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,
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) {
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);
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;
85 } // end namespace llvm
87 // Generated files will use "namespace PPC". To avoid symbol clash,
88 // undefine PPC here. PPC may be predefined on some hosts.
91 // Defines symbolic names for PowerPC registers. This defines a mapping from
92 // register name to register number.
94 #define GET_REGINFO_ENUM
95 #include "PPCGenRegisterInfo.inc"
97 // Defines symbolic names for the PowerPC instructions.
99 #define GET_INSTRINFO_ENUM
100 #include "PPCGenInstrInfo.inc"
102 #define GET_SUBTARGETINFO_ENUM
103 #include "PPCGenSubtargetInfo.inc"
105 #endif // LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H