2012-02-18 13:03:15 +01:00
|
|
|
//===-- PPCRegisterInfo.h - PowerPC Register Information Impl ---*- C++ -*-===//
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2004-08-17 06:55:41 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 01:30:14 +02:00
|
|
|
//
|
2004-08-17 06:55:41 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2008-02-10 19:45:23 +01:00
|
|
|
// This file contains the PowerPC implementation of the TargetRegisterInfo
|
|
|
|
// class.
|
2004-08-17 06:55:41 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 18:26:38 +02:00
|
|
|
#ifndef LLVM_LIB_TARGET_POWERPC_PPCREGISTERINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_POWERPC_PPCREGISTERINFO_H
|
2004-08-17 06:55:41 +02:00
|
|
|
|
2005-10-15 01:51:18 +02:00
|
|
|
#include "PPC.h"
|
2014-01-07 12:48:04 +01:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2004-08-17 06:55:41 +02:00
|
|
|
|
2011-06-27 20:32:37 +02:00
|
|
|
#define GET_REGINFO_HEADER
|
|
|
|
#include "PPCGenRegisterInfo.inc"
|
|
|
|
|
2004-08-17 06:55:41 +02:00
|
|
|
namespace llvm {
|
2015-03-25 20:36:23 +01:00
|
|
|
|
|
|
|
inline static unsigned getCRFromCRBit(unsigned SrcReg) {
|
|
|
|
unsigned Reg = 0;
|
|
|
|
if (SrcReg == PPC::CR0LT || SrcReg == PPC::CR0GT ||
|
|
|
|
SrcReg == PPC::CR0EQ || SrcReg == PPC::CR0UN)
|
|
|
|
Reg = PPC::CR0;
|
|
|
|
else if (SrcReg == PPC::CR1LT || SrcReg == PPC::CR1GT ||
|
|
|
|
SrcReg == PPC::CR1EQ || SrcReg == PPC::CR1UN)
|
|
|
|
Reg = PPC::CR1;
|
|
|
|
else if (SrcReg == PPC::CR2LT || SrcReg == PPC::CR2GT ||
|
|
|
|
SrcReg == PPC::CR2EQ || SrcReg == PPC::CR2UN)
|
|
|
|
Reg = PPC::CR2;
|
|
|
|
else if (SrcReg == PPC::CR3LT || SrcReg == PPC::CR3GT ||
|
|
|
|
SrcReg == PPC::CR3EQ || SrcReg == PPC::CR3UN)
|
|
|
|
Reg = PPC::CR3;
|
|
|
|
else if (SrcReg == PPC::CR4LT || SrcReg == PPC::CR4GT ||
|
|
|
|
SrcReg == PPC::CR4EQ || SrcReg == PPC::CR4UN)
|
|
|
|
Reg = PPC::CR4;
|
|
|
|
else if (SrcReg == PPC::CR5LT || SrcReg == PPC::CR5GT ||
|
|
|
|
SrcReg == PPC::CR5EQ || SrcReg == PPC::CR5UN)
|
|
|
|
Reg = PPC::CR5;
|
|
|
|
else if (SrcReg == PPC::CR6LT || SrcReg == PPC::CR6GT ||
|
|
|
|
SrcReg == PPC::CR6EQ || SrcReg == PPC::CR6UN)
|
|
|
|
Reg = PPC::CR6;
|
|
|
|
else if (SrcReg == PPC::CR7LT || SrcReg == PPC::CR7GT ||
|
|
|
|
SrcReg == PPC::CR7EQ || SrcReg == PPC::CR7UN)
|
|
|
|
Reg = PPC::CR7;
|
|
|
|
|
|
|
|
assert(Reg != 0 && "Invalid CR bit register");
|
|
|
|
return Reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-16 07:39:50 +02:00
|
|
|
class PPCRegisterInfo : public PPCGenRegisterInfo {
|
2013-03-31 16:43:31 +02:00
|
|
|
DenseMap<unsigned, unsigned> ImmToIdxMap;
|
2015-03-12 02:42:51 +01:00
|
|
|
const PPCTargetMachine &TM;
|
2004-08-17 06:55:41 +02:00
|
|
|
public:
|
2015-03-12 02:42:51 +01:00
|
|
|
PPCRegisterInfo(const PPCTargetMachine &TM);
|
2006-04-17 23:07:20 +02:00
|
|
|
|
2009-02-06 18:43:24 +01:00
|
|
|
/// getPointerRegClass - Return the register class to use to hold pointers.
|
|
|
|
/// This is used for addressing modes.
|
2014-04-29 09:57:37 +02:00
|
|
|
const TargetRegisterClass *
|
|
|
|
getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override;
|
2009-02-06 18:43:24 +01:00
|
|
|
|
2011-11-22 17:21:04 +01:00
|
|
|
unsigned getRegPressureLimit(const TargetRegisterClass *RC,
|
2014-04-29 09:57:37 +02:00
|
|
|
MachineFunction &MF) const override;
|
2011-11-22 17:21:04 +01:00
|
|
|
|
2015-03-11 00:46:01 +01:00
|
|
|
const TargetRegisterClass *
|
|
|
|
getLargestLegalSuperClass(const TargetRegisterClass *RC,
|
|
|
|
const MachineFunction &MF) const override;
|
2014-03-29 06:29:01 +01:00
|
|
|
|
2004-08-17 06:55:41 +02:00
|
|
|
/// Code Generation virtual methods...
|
2015-03-11 23:24:37 +01:00
|
|
|
const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
|
2015-03-11 23:42:13 +01:00
|
|
|
const uint32_t *getCallPreservedMask(const MachineFunction &MF,
|
|
|
|
CallingConv::ID CC) const override;
|
2013-03-21 22:37:52 +01:00
|
|
|
const uint32_t *getNoPreservedMask() const;
|
2006-05-18 02:12:58 +02:00
|
|
|
|
Revert "r225811 - Revert "r225808 - [PowerPC] Add StackMap/PatchPoint support""
This re-applies r225808, fixed to avoid problems with SDAG dependencies along
with the preceding fix to ScheduleDAGSDNodes::RegDefIter::InitNodeNumDefs.
These problems caused the original regression tests to assert/segfault on many
(but not all) systems.
Original commit message:
This commit does two things:
1. Refactors PPCFastISel to use more of the common infrastructure for call
lowering (this lets us take advantage of this common code for lowering some
common intrinsics, stackmap/patchpoint among them).
2. Adds support for stackmap/patchpoint lowering. For the most part, this is
very similar to the support in the AArch64 target, with the obvious differences
(different registers, NOP instructions, etc.). The test cases are adapted
from the AArch64 test cases.
One difference of note is that the patchpoint call sequence takes 24 bytes, so
you can't use less than that (on AArch64 you can go down to 16). Also, as noted
in the docs, we take the patchpoint address to be the actual code address
(assuming the call is local in the TOC-sharing sense), which should yield
higher performance than generating the full cross-DSO indirect-call sequence
and is likely just as useful for JITed code (if not, we'll change it).
StackMaps and Patchpoints are still marked as experimental, and so this support
is doubly experimental. So go ahead and experiment!
llvm-svn: 225909
2015-01-14 02:07:51 +01:00
|
|
|
void adjustStackMapLiveOutMask(uint32_t *Mask) const override;
|
|
|
|
|
2014-04-29 09:57:37 +02:00
|
|
|
BitVector getReservedRegs(const MachineFunction &MF) const override;
|
2007-02-19 22:49:54 +01:00
|
|
|
|
2013-03-14 21:21:47 +01:00
|
|
|
/// We require the register scavenger.
|
2014-04-29 09:57:37 +02:00
|
|
|
bool requiresRegisterScavenging(const MachineFunction &MF) const override {
|
2013-03-12 15:12:16 +01:00
|
|
|
return true;
|
|
|
|
}
|
2008-03-03 23:19:16 +01:00
|
|
|
|
2014-04-29 09:57:37 +02:00
|
|
|
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override {
|
2013-03-14 21:21:47 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-29 09:57:37 +02:00
|
|
|
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override {
|
2013-03-14 21:21:47 +01:00
|
|
|
return true;
|
|
|
|
}
|
2012-04-23 23:39:35 +02:00
|
|
|
|
2014-04-29 09:57:37 +02:00
|
|
|
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override {
|
2013-04-09 19:27:09 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-23 20:36:47 +01:00
|
|
|
void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
|
|
|
|
void lowerCRSpilling(MachineBasicBlock::iterator II,
|
|
|
|
unsigned FrameIndex) const;
|
|
|
|
void lowerCRRestore(MachineBasicBlock::iterator II,
|
|
|
|
unsigned FrameIndex) const;
|
Add CR-bit tracking to the PowerPC backend for i1 values
This change enables tracking i1 values in the PowerPC backend using the
condition register bits. These bits can be treated on PowerPC as separate
registers; individual bit operations (and, or, xor, etc.) are supported.
Tracking booleans in CR bits has several advantages:
- Reduction in register pressure (because we no longer need GPRs to store
boolean values).
- Logical operations on booleans can be handled more efficiently; we used to
have to move all results from comparisons into GPRs, perform promoted
logical operations in GPRs, and then move the result back into condition
register bits to be used by conditional branches. This can be very
inefficient, because the throughput of these CR <-> GPR moves have high
latency and low throughput (especially when other associated instructions
are accounted for).
- On the POWER7 and similar cores, we can increase total throughput by using
the CR bits. CR bit operations have a dedicated functional unit.
Most of this is more-or-less mechanical: Adjustments were needed in the
calling-convention code, support was added for spilling/restoring individual
condition-register bits, and conditional branch instruction definitions taking
specific CR bits were added (plus patterns and code for generating bit-level
operations).
This is enabled by default when running at -O2 and higher. For -O0 and -O1,
where the ability to debug is more important, this feature is disabled by
default. Individual CR bits do not have assigned DWARF register numbers,
and storing values in CR bits makes them invisible to the debugger.
It is critical, however, that we don't move i1 values that have been promoted
to larger values (such as those passed as function arguments) into bit
registers only to quickly turn around and move the values back into GPRs (such
as happens when values are returned by functions). A pair of target-specific
DAG combines are added to remove the trunc/extends in:
trunc(binary-ops(binary-ops(zext(x), zext(y)), ...)
and:
zext(binary-ops(binary-ops(trunc(x), trunc(y)), ...)
In short, we only want to use CR bits where some of the i1 values come from
comparisons or are used by conditional branches or selects. To put it another
way, if we can do the entire i1 computation in GPRs, then we probably should
(on the POWER7, the GPR-operation throughput is higher, and for all cores, the
CR <-> GPR moves are expensive).
POWER7 test-suite performance results (from 10 runs in each configuration):
SingleSource/Benchmarks/Misc/mandel-2: 35% speedup
MultiSource/Benchmarks/Prolangs-C++/city/city: 21% speedup
MultiSource/Benchmarks/MiBench/automotive-susan: 23% speedup
SingleSource/Benchmarks/CoyoteBench/huffbench: 13% speedup
SingleSource/Benchmarks/Misc-C++/Large/sphereflake: 13% speedup
SingleSource/Benchmarks/Misc-C++/mandel-text: 10% speedup
SingleSource/Benchmarks/Misc-C++-EH/spirit: 10% slowdown
MultiSource/Applications/lemon/lemon: 8% slowdown
llvm-svn: 202451
2014-02-28 01:27:01 +01:00
|
|
|
void lowerCRBitSpilling(MachineBasicBlock::iterator II,
|
|
|
|
unsigned FrameIndex) const;
|
|
|
|
void lowerCRBitRestore(MachineBasicBlock::iterator II,
|
|
|
|
unsigned FrameIndex) const;
|
2013-03-23 20:36:47 +01:00
|
|
|
void lowerVRSAVESpilling(MachineBasicBlock::iterator II,
|
|
|
|
unsigned FrameIndex) const;
|
|
|
|
void lowerVRSAVERestore(MachineBasicBlock::iterator II,
|
|
|
|
unsigned FrameIndex) const;
|
2013-03-21 20:03:21 +01:00
|
|
|
|
2012-09-12 16:47:47 +02:00
|
|
|
bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
|
2014-04-29 09:57:37 +02:00
|
|
|
int &FrameIdx) const override;
|
2010-08-27 01:32:16 +02:00
|
|
|
void eliminateFrameIndex(MachineBasicBlock::iterator II,
|
2013-01-31 21:02:54 +01:00
|
|
|
int SPAdj, unsigned FIOperandNum,
|
2014-04-29 09:57:37 +02:00
|
|
|
RegScavenger *RS = nullptr) const override;
|
2004-08-17 06:55:41 +02:00
|
|
|
|
2013-04-09 19:27:09 +02:00
|
|
|
// Support for virtual base registers.
|
2014-04-29 09:57:37 +02:00
|
|
|
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override;
|
2013-04-09 19:27:09 +02:00
|
|
|
void materializeFrameBaseRegister(MachineBasicBlock *MBB,
|
|
|
|
unsigned BaseReg, int FrameIdx,
|
2014-04-29 09:57:37 +02:00
|
|
|
int64_t Offset) const override;
|
2014-04-02 21:28:18 +02:00
|
|
|
void resolveFrameIndex(MachineInstr &MI, unsigned BaseReg,
|
2014-04-29 09:57:37 +02:00
|
|
|
int64_t Offset) const override;
|
2015-03-20 18:20:07 +01:00
|
|
|
bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg,
|
2014-04-29 09:57:37 +02:00
|
|
|
int64_t Offset) const override;
|
2013-04-09 19:27:09 +02:00
|
|
|
|
2006-03-28 15:48:33 +02:00
|
|
|
// Debug information queries.
|
2014-04-29 09:57:37 +02:00
|
|
|
unsigned getFrameRegister(const MachineFunction &MF) const override;
|
2007-02-21 23:54:50 +01:00
|
|
|
|
2013-07-17 02:45:52 +02:00
|
|
|
// Base pointer (stack realignment) support.
|
|
|
|
unsigned getBaseRegister(const MachineFunction &MF) const;
|
|
|
|
bool hasBasePointer(const MachineFunction &MF) const;
|
|
|
|
bool canRealignStack(const MachineFunction &MF) const;
|
2014-04-29 09:57:37 +02:00
|
|
|
bool needsStackRealignment(const MachineFunction &MF) const override;
|
2004-08-17 06:55:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|