mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-10 17:07:06 +00:00
a68f58ab2b
A setting in MCAsmInfo defines the "assembler dialect" to use. This is used by common code to choose between alternatives in a multi-alternative GNU inline asm statement like the following: __asm__ ("{sfe|subfe} %0,%1,%2" : "=r" (out) : "r" (in1), "r" (in2)); The meaning of these dialects is platform specific, and GCC defines those for PowerPC to use dialect 0 for old-style (POWER) mnemonics and 1 for new-style (PowerPC) mnemonics, like in the example above. To be compatible with inline asm used with GCC, LLVM ought to do the same. Specifically, this means we should always use assembler dialect 1 since old-style mnemonics really aren't supported on any current platform. However, the current LLVM back-end uses: AssemblerDialect = 1; // New-Style mnemonics. in PPCMCAsmInfoDarwin, and AssemblerDialect = 0; // Old-Style mnemonics. in PPCLinuxMCAsmInfo. The Linux setting really isn't correct, we should be using new-style mnemonics everywhere. This is changed by this commit. Unfortunately, the setting of this variable is overloaded in the back-end to decide whether or not we are on a Darwin target. This is done in PPCInstPrinter (the "SyntaxVariant" is initialized from the MCAsmInfo AssemblerDialect setting), and also in PPCMCExpr. Setting AssemblerDialect to 1 for both Darwin and Linux no longer allows us to make this distinction. Instead, this patch uses the MCSubtargetInfo passed to createPPCMCInstPrinter to distinguish Darwin targets, and ignores the SyntaxVariant parameter. As to PPCMCExpr, this patch adds an explicit isDarwin argument that needs to be passed in by the caller when creating a target MCExpr. (To do so this patch implicitly also reverts commit 184441.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185858 91177308-0d34-0410-b5e6-96231b3b80d8
97 lines
2.5 KiB
C++
97 lines
2.5 KiB
C++
//===-- PPCMCExpr.h - PPC specific MC expression classes --------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef PPCMCEXPR_H
|
|
#define PPCMCEXPR_H
|
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
#include "llvm/MC/MCValue.h"
|
|
#include "llvm/MC/MCAsmLayout.h"
|
|
|
|
namespace llvm {
|
|
|
|
class PPCMCExpr : public MCTargetExpr {
|
|
public:
|
|
enum VariantKind {
|
|
VK_PPC_None,
|
|
VK_PPC_LO,
|
|
VK_PPC_HI,
|
|
VK_PPC_HA,
|
|
VK_PPC_HIGHER,
|
|
VK_PPC_HIGHERA,
|
|
VK_PPC_HIGHEST,
|
|
VK_PPC_HIGHESTA
|
|
};
|
|
|
|
private:
|
|
const VariantKind Kind;
|
|
const MCExpr *Expr;
|
|
bool IsDarwin;
|
|
|
|
explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr,
|
|
bool _IsDarwin)
|
|
: Kind(_Kind), Expr(_Expr), IsDarwin(_IsDarwin) {}
|
|
|
|
public:
|
|
/// @name Construction
|
|
/// @{
|
|
|
|
static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
|
|
bool isDarwin, MCContext &Ctx);
|
|
|
|
static const PPCMCExpr *CreateLo(const MCExpr *Expr,
|
|
bool isDarwin, MCContext &Ctx) {
|
|
return Create(VK_PPC_LO, Expr, isDarwin, Ctx);
|
|
}
|
|
|
|
static const PPCMCExpr *CreateHi(const MCExpr *Expr,
|
|
bool isDarwin, MCContext &Ctx) {
|
|
return Create(VK_PPC_HI, Expr, isDarwin, Ctx);
|
|
}
|
|
|
|
static const PPCMCExpr *CreateHa(const MCExpr *Expr,
|
|
bool isDarwin, MCContext &Ctx) {
|
|
return Create(VK_PPC_HA, Expr, isDarwin, Ctx);
|
|
}
|
|
|
|
/// @}
|
|
/// @name Accessors
|
|
/// @{
|
|
|
|
/// getOpcode - Get the kind of this expression.
|
|
VariantKind getKind() const { return Kind; }
|
|
|
|
/// getSubExpr - Get the child of this expression.
|
|
const MCExpr *getSubExpr() const { return Expr; }
|
|
|
|
/// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
|
|
bool isDarwinSyntax() const { return IsDarwin; }
|
|
|
|
|
|
/// @}
|
|
|
|
void PrintImpl(raw_ostream &OS) const;
|
|
bool EvaluateAsRelocatableImpl(MCValue &Res,
|
|
const MCAsmLayout *Layout) const;
|
|
void AddValueSymbols(MCAssembler *) const;
|
|
const MCSection *FindAssociatedSection() const {
|
|
return getSubExpr()->FindAssociatedSection();
|
|
}
|
|
|
|
// There are no TLS PPCMCExprs at the moment.
|
|
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
|
|
|
|
static bool classof(const MCExpr *E) {
|
|
return E->getKind() == MCExpr::Target;
|
|
}
|
|
};
|
|
} // end namespace llvm
|
|
|
|
#endif
|