2011-07-15 04:59:42 +08:00
|
|
|
//===-- PPCMCTargetDesc.h - PowerPC Target Descriptions ---------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides PowerPC specific target descriptions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
|
|
|
|
#define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
|
2011-07-15 04:59:42 +08:00
|
|
|
|
2012-12-20 13:13:09 +08:00
|
|
|
// GCC #defines PPC on Linux but we use it as our namespace name
|
|
|
|
#undef PPC
|
|
|
|
|
2015-03-29 03:42:41 +08:00
|
|
|
#include "llvm/Support/MathExtras.h"
|
2017-01-13 08:58:58 +08:00
|
|
|
#include <cstdint>
|
2017-10-11 00:58:26 +08:00
|
|
|
#include <memory>
|
2011-12-22 09:57:09 +08:00
|
|
|
|
2011-07-15 04:59:42 +08:00
|
|
|
namespace llvm {
|
2017-01-13 08:58:58 +08:00
|
|
|
|
2011-07-26 07:24:55 +08:00
|
|
|
class MCAsmBackend;
|
2011-07-26 03:53:23 +08:00
|
|
|
class MCCodeEmitter;
|
|
|
|
class MCContext;
|
|
|
|
class MCInstrInfo;
|
2011-12-22 09:57:09 +08:00
|
|
|
class MCObjectWriter;
|
2012-05-16 01:35:52 +08:00
|
|
|
class MCRegisterInfo;
|
2018-01-03 16:53:05 +08:00
|
|
|
class MCSubtargetInfo;
|
2016-07-26 01:18:28 +08:00
|
|
|
class MCTargetOptions;
|
2011-07-15 04:59:42 +08:00
|
|
|
class Target;
|
2015-09-16 00:17:27 +08:00
|
|
|
class Triple;
|
2011-07-15 04:59:42 +08:00
|
|
|
class StringRef;
|
2015-04-15 06:14:34 +08:00
|
|
|
class raw_pwrite_stream;
|
2011-07-15 04:59:42 +08:00
|
|
|
|
2016-10-10 07:00:34 +08:00
|
|
|
Target &getThePPC32Target();
|
|
|
|
Target &getThePPC64Target();
|
|
|
|
Target &getThePPC64LETarget();
|
2015-03-11 06:03:14 +08:00
|
|
|
|
2011-07-26 03:53:23 +08:00
|
|
|
MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
|
2012-05-16 01:35:52 +08:00
|
|
|
const MCRegisterInfo &MRI,
|
2011-07-26 03:53:23 +08:00
|
|
|
MCContext &Ctx);
|
|
|
|
|
2018-01-03 16:53:05 +08:00
|
|
|
MCAsmBackend *createPPCAsmBackend(const Target &T, const MCSubtargetInfo &STI,
|
|
|
|
const MCRegisterInfo &MRI,
|
2016-07-26 01:18:28 +08:00
|
|
|
const MCTargetOptions &Options);
|
2011-12-22 09:57:09 +08:00
|
|
|
|
2015-04-10 01:10:57 +08:00
|
|
|
/// Construct an PPC ELF object writer.
|
2017-10-11 00:28:07 +08:00
|
|
|
std::unique_ptr<MCObjectWriter> createPPCELFObjectWriter(raw_pwrite_stream &OS,
|
|
|
|
bool Is64Bit,
|
|
|
|
bool IsLittleEndian,
|
|
|
|
uint8_t OSABI);
|
2015-04-10 01:10:57 +08:00
|
|
|
/// Construct a PPC Mach-O object writer.
|
2017-10-11 00:28:07 +08:00
|
|
|
std::unique_ptr<MCObjectWriter> createPPCMachObjectWriter(raw_pwrite_stream &OS,
|
|
|
|
bool Is64Bit,
|
|
|
|
uint32_t CPUType,
|
|
|
|
uint32_t CPUSubtype);
|
2015-03-29 03:42:41 +08:00
|
|
|
|
2015-04-10 01:10:57 +08:00
|
|
|
/// Returns true iff Val consists of one contiguous run of 1s with any number of
|
|
|
|
/// 0s on either side. The 1s are allowed to wrap from LSB to MSB, so
|
|
|
|
/// 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is not,
|
|
|
|
/// since all 1s are not contiguous.
|
2015-03-29 03:42:41 +08:00
|
|
|
static inline bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME) {
|
|
|
|
if (!Val)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (isShiftedMask_32(Val)) {
|
|
|
|
// look for the first non-zero bit
|
|
|
|
MB = countLeadingZeros(Val);
|
|
|
|
// look for the first zero bit after the run of ones
|
|
|
|
ME = countLeadingZeros((Val - 1) ^ Val);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Val = ~Val; // invert mask
|
|
|
|
if (isShiftedMask_32(Val)) {
|
|
|
|
// effectively look for the first zero bit
|
|
|
|
ME = countLeadingZeros(Val) - 1;
|
|
|
|
// effectively look for the first one bit after the run of zeros
|
|
|
|
MB = countLeadingZeros((Val - 1) ^ Val) + 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// no run present
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-13 08:58:58 +08:00
|
|
|
} // end namespace llvm
|
2011-07-15 04:59:42 +08:00
|
|
|
|
2013-03-17 20:40:42 +08:00
|
|
|
// Generated files will use "namespace PPC". To avoid symbol clash,
|
|
|
|
// undefine PPC here. PPC may be predefined on some hosts.
|
|
|
|
#undef PPC
|
|
|
|
|
2011-07-15 04:59:42 +08:00
|
|
|
// Defines symbolic names for PowerPC registers. This defines a mapping from
|
|
|
|
// register name to register number.
|
|
|
|
//
|
|
|
|
#define GET_REGINFO_ENUM
|
|
|
|
#include "PPCGenRegisterInfo.inc"
|
|
|
|
|
|
|
|
// Defines symbolic names for the PowerPC instructions.
|
|
|
|
//
|
|
|
|
#define GET_INSTRINFO_ENUM
|
2017-12-13 15:26:17 +08:00
|
|
|
#define GET_INSTRINFO_SCHED_ENUM
|
2011-07-15 04:59:42 +08:00
|
|
|
#include "PPCGenInstrInfo.inc"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_ENUM
|
|
|
|
#include "PPCGenSubtargetInfo.inc"
|
|
|
|
|
2017-01-13 08:58:58 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCTARGETDESC_H
|