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/DataTypes.h"
21 #include "llvm/Support/MathExtras.h"
30 class MCSubtargetInfo;
35 extern Target ThePPC32Target;
36 extern Target ThePPC64Target;
37 extern Target ThePPC64LETarget;
39 MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
40 const MCRegisterInfo &MRI,
43 MCAsmBackend *createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI,
44 StringRef TT, StringRef CPU);
46 /// createPPCELFObjectWriter - Construct an PPC ELF object writer.
47 MCObjectWriter *createPPCELFObjectWriter(raw_ostream &OS,
51 /// createPPCELFObjectWriter - Construct a PPC Mach-O object writer.
52 MCObjectWriter *createPPCMachObjectWriter(raw_ostream &OS, bool Is64Bit,
56 /// isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s with
57 /// any number of 0s on either side. The 1s are allowed to wrap from LSB to
58 /// MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is
59 /// not, since all 1s are not contiguous.
60 static inline bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME) {
64 if (isShiftedMask_32(Val)) {
65 // look for the first non-zero bit
66 MB = countLeadingZeros(Val);
67 // look for the first zero bit after the run of ones
68 ME = countLeadingZeros((Val - 1) ^ Val);
71 Val = ~Val; // invert mask
72 if (isShiftedMask_32(Val)) {
73 // effectively look for the first zero bit
74 ME = countLeadingZeros(Val) - 1;
75 // effectively look for the first one bit after the run of zeros
76 MB = countLeadingZeros((Val - 1) ^ Val) + 1;
84 } // End llvm namespace
86 // Generated files will use "namespace PPC". To avoid symbol clash,
87 // undefine PPC here. PPC may be predefined on some hosts.
90 // Defines symbolic names for PowerPC registers. This defines a mapping from
91 // register name to register number.
93 #define GET_REGINFO_ENUM
94 #include "PPCGenRegisterInfo.inc"
96 // Defines symbolic names for the PowerPC instructions.
98 #define GET_INSTRINFO_ENUM
99 #include "PPCGenInstrInfo.inc"
101 #define GET_SUBTARGETINFO_ENUM
102 #include "PPCGenSubtargetInfo.inc"