2013-05-07 00:15:19 +08:00
|
|
|
//===-- SystemZCallingConv.h - Calling conventions for SystemZ --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
|
|
|
|
#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZCALLINGCONV_H
|
2013-05-07 00:15:19 +08:00
|
|
|
|
[SystemZ] Add CodeGen support for integer vector types
This the first of a series of patches to add CodeGen support exploiting
the instructions of the z13 vector facility. This patch adds support
for the native integer vector types (v16i8, v8i16, v4i32, v2i64).
When the vector facility is present, we default to the new vector ABI.
This is characterized by two major differences:
- Vector types are passed/returned in vector registers
(except for unnamed arguments of a variable-argument list function).
- Vector types are at most 8-byte aligned.
The reason for the choice of 8-byte vector alignment is that the hardware
is able to efficiently load vectors at 8-byte alignment, and the ABI only
guarantees 8-byte alignment of the stack pointer, so requiring any higher
alignment for vectors would require dynamic stack re-alignment code.
However, for compatibility with old code that may use vector types, when
*not* using the vector facility, the old alignment rules (vector types
are naturally aligned) remain in use.
These alignment rules are not only implemented at the C language level
(implemented in clang), but also at the LLVM IR level. This is done
by selecting a different DataLayout string depending on whether the
vector ABI is in effect or not.
Based on a patch by Richard Sandiford.
llvm-svn: 236521
2015-05-06 03:25:42 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/CodeGen/CallingConvLower.h"
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
namespace llvm {
|
2014-03-06 18:38:30 +08:00
|
|
|
namespace SystemZ {
|
|
|
|
const unsigned NumArgGPRs = 5;
|
|
|
|
extern const unsigned ArgGPRs[NumArgGPRs];
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2014-03-06 18:38:30 +08:00
|
|
|
const unsigned NumArgFPRs = 4;
|
|
|
|
extern const unsigned ArgFPRs[NumArgFPRs];
|
|
|
|
} // end namespace SystemZ
|
[SystemZ] Add CodeGen support for integer vector types
This the first of a series of patches to add CodeGen support exploiting
the instructions of the z13 vector facility. This patch adds support
for the native integer vector types (v16i8, v8i16, v4i32, v2i64).
When the vector facility is present, we default to the new vector ABI.
This is characterized by two major differences:
- Vector types are passed/returned in vector registers
(except for unnamed arguments of a variable-argument list function).
- Vector types are at most 8-byte aligned.
The reason for the choice of 8-byte vector alignment is that the hardware
is able to efficiently load vectors at 8-byte alignment, and the ABI only
guarantees 8-byte alignment of the stack pointer, so requiring any higher
alignment for vectors would require dynamic stack re-alignment code.
However, for compatibility with old code that may use vector types, when
*not* using the vector facility, the old alignment rules (vector types
are naturally aligned) remain in use.
These alignment rules are not only implemented at the C language level
(implemented in clang), but also at the LLVM IR level. This is done
by selecting a different DataLayout string depending on whether the
vector ABI is in effect or not.
Based on a patch by Richard Sandiford.
llvm-svn: 236521
2015-05-06 03:25:42 +08:00
|
|
|
|
|
|
|
class SystemZCCState : public CCState {
|
|
|
|
private:
|
|
|
|
/// Records whether the value was a fixed argument.
|
|
|
|
/// See ISD::OutputArg::IsFixed.
|
|
|
|
SmallVector<bool, 4> ArgIsFixed;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SystemZCCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
|
|
|
|
SmallVectorImpl<CCValAssign> &locs, LLVMContext &C)
|
|
|
|
: CCState(CC, isVarArg, MF, locs, C) {}
|
|
|
|
|
|
|
|
void AnalyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
CCAssignFn Fn) {
|
|
|
|
// Formal arguments are always fixed.
|
|
|
|
ArgIsFixed.clear();
|
|
|
|
for (unsigned i = 0; i < Ins.size(); ++i)
|
|
|
|
ArgIsFixed.push_back(true);
|
|
|
|
|
|
|
|
CCState::AnalyzeFormalArguments(Ins, Fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
CCAssignFn Fn) {
|
|
|
|
// Record whether the call operand was a fixed argument.
|
|
|
|
ArgIsFixed.clear();
|
|
|
|
for (unsigned i = 0; i < Outs.size(); ++i)
|
|
|
|
ArgIsFixed.push_back(Outs[i].IsFixed);
|
|
|
|
|
|
|
|
CCState::AnalyzeCallOperands(Outs, Fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This version of AnalyzeCallOperands in the base class is not usable
|
|
|
|
// since we must provide a means of accessing ISD::OutputArg::IsFixed.
|
|
|
|
void AnalyzeCallOperands(const SmallVectorImpl<MVT> &Outs,
|
|
|
|
SmallVectorImpl<ISD::ArgFlagsTy> &Flags,
|
|
|
|
CCAssignFn Fn) = delete;
|
|
|
|
|
|
|
|
bool IsFixed(unsigned ValNo) { return ArgIsFixed[ValNo]; }
|
|
|
|
};
|
|
|
|
|
2014-03-06 18:38:30 +08:00
|
|
|
} // end namespace llvm
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
#endif
|