blob: 5f2117c88e46f8279bb08a53cb88d0106e15be53 [file] [log] [blame]
Evan Chengbc153d42011-07-14 20:59:42 +00001//===-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
15#define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
Evan Chengbc153d42011-07-14 20:59:42 +000016
Rafael Espindolafb8ac2d2012-12-20 05:13:09 +000017// GCC #defines PPC on Linux but we use it as our namespace name
18#undef PPC
19
Rafael Espindola38a400d2011-12-22 01:57:09 +000020#include "llvm/Support/DataTypes.h"
Hal Finkel6e9110a2015-03-28 19:42:41 +000021#include "llvm/Support/MathExtras.h"
Rafael Espindola38a400d2011-12-22 01:57:09 +000022
Evan Chengbc153d42011-07-14 20:59:42 +000023namespace llvm {
Evan Cheng5928e692011-07-25 23:24:55 +000024class MCAsmBackend;
Evan Cheng61d4a202011-07-25 19:53:23 +000025class MCCodeEmitter;
26class MCContext;
27class MCInstrInfo;
Rafael Espindola38a400d2011-12-22 01:57:09 +000028class MCObjectWriter;
Jim Grosbachc3b04272012-05-15 17:35:52 +000029class MCRegisterInfo;
Evan Chengbc153d42011-07-14 20:59:42 +000030class MCSubtargetInfo;
31class Target;
32class StringRef;
Rafael Espindola5560a4c2015-04-14 22:14:34 +000033class raw_pwrite_stream;
Rafael Espindola38a400d2011-12-22 01:57:09 +000034class raw_ostream;
Evan Chengbc153d42011-07-14 20:59:42 +000035
36extern Target ThePPC32Target;
37extern Target ThePPC64Target;
Bill Schmidt0a9170d2013-07-26 01:35:43 +000038extern Target ThePPC64LETarget;
Eric Christopher0169e422015-03-10 22:03:14 +000039
Evan Cheng61d4a202011-07-25 19:53:23 +000040MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
Jim Grosbachc3b04272012-05-15 17:35:52 +000041 const MCRegisterInfo &MRI,
Evan Cheng61d4a202011-07-25 19:53:23 +000042 MCContext &Ctx);
43
Bill Wendling58e2d3d2013-09-09 02:37:14 +000044MCAsmBackend *createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI,
45 StringRef TT, StringRef CPU);
Rafael Espindola38a400d2011-12-22 01:57:09 +000046
Rafael Espindoladf7305a2015-04-09 17:10:57 +000047/// Construct an PPC ELF object writer.
Rafael Espindola5560a4c2015-04-14 22:14:34 +000048MCObjectWriter *createPPCELFObjectWriter(raw_pwrite_stream &OS, bool Is64Bit,
49 bool IsLittleEndian, uint8_t OSABI);
Rafael Espindoladf7305a2015-04-09 17:10:57 +000050/// Construct a PPC Mach-O object writer.
Rafael Espindola5560a4c2015-04-14 22:14:34 +000051MCObjectWriter *createPPCMachObjectWriter(raw_pwrite_stream &OS, bool Is64Bit,
David Fangb88cdf62013-08-08 20:14:40 +000052 uint32_t CPUType,
53 uint32_t CPUSubtype);
Hal Finkel6e9110a2015-03-28 19:42:41 +000054
Rafael Espindoladf7305a2015-04-09 17:10:57 +000055/// Returns true iff Val consists of one contiguous run of 1s with any number of
56/// 0s on either side. The 1s are allowed to wrap from LSB to MSB, so
57/// 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is not,
58/// since all 1s are not contiguous.
Hal Finkel6e9110a2015-03-28 19:42:41 +000059static inline bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME) {
60 if (!Val)
61 return false;
62
63 if (isShiftedMask_32(Val)) {
64 // look for the first non-zero bit
65 MB = countLeadingZeros(Val);
66 // look for the first zero bit after the run of ones
67 ME = countLeadingZeros((Val - 1) ^ Val);
68 return true;
69 } else {
70 Val = ~Val; // invert mask
71 if (isShiftedMask_32(Val)) {
72 // effectively look for the first zero bit
73 ME = countLeadingZeros(Val) - 1;
74 // effectively look for the first one bit after the run of zeros
75 MB = countLeadingZeros((Val - 1) ^ Val) + 1;
76 return true;
77 }
78 }
79 // no run present
80 return false;
81}
82
Evan Chengbc153d42011-07-14 20:59:42 +000083} // End llvm namespace
84
Sylvestre Ledru37ef20d2013-03-17 12:40:42 +000085// Generated files will use "namespace PPC". To avoid symbol clash,
86// undefine PPC here. PPC may be predefined on some hosts.
87#undef PPC
88
Evan Chengbc153d42011-07-14 20:59:42 +000089// Defines symbolic names for PowerPC registers. This defines a mapping from
90// register name to register number.
91//
92#define GET_REGINFO_ENUM
93#include "PPCGenRegisterInfo.inc"
94
95// Defines symbolic names for the PowerPC instructions.
96//
97#define GET_INSTRINFO_ENUM
98#include "PPCGenInstrInfo.inc"
99
100#define GET_SUBTARGETINFO_ENUM
101#include "PPCGenSubtargetInfo.inc"
102
103#endif