[Mips] s/context/ctx/ for consistency and reduce lines lengths.

No functional changes.

llvm-svn: 213310
This commit is contained in:
Simon Atanasyan 2014-07-17 20:57:54 +00:00
parent 31a38cc32f
commit c2d8d6d489
8 changed files with 42 additions and 48 deletions

View File

@ -22,7 +22,7 @@ template <typename ELFT> class MipsTargetLayout;
template <class ELFT>
class MipsDynamicLibraryWriter : public DynamicLibraryWriter<ELFT> {
public:
MipsDynamicLibraryWriter(MipsLinkingContext &context,
MipsDynamicLibraryWriter(MipsLinkingContext &ctx,
MipsTargetLayout<ELFT> &layout);
protected:
@ -57,10 +57,9 @@ private:
template <class ELFT>
MipsDynamicLibraryWriter<ELFT>::MipsDynamicLibraryWriter(
MipsLinkingContext &context, MipsTargetLayout<ELFT> &layout)
: DynamicLibraryWriter<ELFT>(context, layout),
_writeHelper(context, layout),
_mipsContext(context), _mipsTargetLayout(layout) {}
MipsLinkingContext &ctx, MipsTargetLayout<ELFT> &layout)
: DynamicLibraryWriter<ELFT>(ctx, layout), _writeHelper(ctx, layout),
_mipsContext(ctx), _mipsTargetLayout(layout) {}
template <class ELFT>
bool MipsDynamicLibraryWriter<ELFT>::createImplicitFiles(

View File

@ -21,9 +21,9 @@ template <class ELFType> class MipsTargetLayout;
template <class MipsELFType>
class MipsDynamicTable : public DynamicTable<MipsELFType> {
public:
MipsDynamicTable(MipsLinkingContext &context,
MipsDynamicTable(MipsLinkingContext &ctx,
MipsTargetLayout<MipsELFType> &layout)
: DynamicTable<MipsELFType>(context, layout, ".dynamic",
: DynamicTable<MipsELFType>(ctx, layout, ".dynamic",
DefaultLayout<MipsELFType>::ORDER_DYNAMIC),
_mipsTargetLayout(layout) {}

View File

@ -19,9 +19,8 @@ template <class ELFT> class MipsTargetLayout;
template <typename ELFT> class MipsELFWriter {
public:
MipsELFWriter(MipsLinkingContext &context,
MipsTargetLayout<ELFT> &targetLayout)
: _context(context), _targetLayout(targetLayout) {}
MipsELFWriter(MipsLinkingContext &ctx, MipsTargetLayout<ELFT> &targetLayout)
: _ctx(ctx), _targetLayout(targetLayout) {}
void setELFHeader(ELFHeader<ELFT> &elfHeader) {
elfHeader.e_version(1);
@ -36,13 +35,13 @@ public:
// merge them and write result here.
uint32_t flags = llvm::ELF::EF_MIPS_NOREORDER | llvm::ELF::EF_MIPS_ABI_O32 |
llvm::ELF::EF_MIPS_CPIC | llvm::ELF::EF_MIPS_ARCH_32R2;
if (_context.getOutputELFType() == llvm::ELF::ET_DYN)
if (_ctx.getOutputELFType() == llvm::ELF::ET_DYN)
flags |= EF_MIPS_PIC;
elfHeader.e_flags(flags);
}
void finalizeMipsRuntimeAtomValues() {
if (!_context.isDynamic())
if (!_ctx.isDynamic())
return;
auto gotSection = _targetLayout.findOutputSection(".got");
@ -60,8 +59,8 @@ public:
}
std::unique_ptr<MipsRuntimeFile<ELFT>> createRuntimeFile() {
auto file = llvm::make_unique<MipsRuntimeFile<ELFT>>(_context);
if (_context.isDynamic()) {
auto file = llvm::make_unique<MipsRuntimeFile<ELFT>>(_ctx);
if (_ctx.isDynamic()) {
file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
file->addAbsoluteAtom("_gp");
file->addAbsoluteAtom("_gp_disp");
@ -80,7 +79,7 @@ public:
}
private:
MipsLinkingContext &_context;
MipsLinkingContext &_ctx;
MipsTargetLayout<ELFT> &_targetLayout;
void setAtomValue(StringRef name, uint64_t value) {

View File

@ -22,8 +22,7 @@ template <typename ELFT> class MipsTargetLayout;
template <class ELFT>
class MipsExecutableWriter : public ExecutableWriter<ELFT> {
public:
MipsExecutableWriter(MipsLinkingContext &context,
MipsTargetLayout<ELFT> &layout);
MipsExecutableWriter(MipsLinkingContext &ctx, MipsTargetLayout<ELFT> &layout);
protected:
void buildDynamicSymbolTable(const File &file) override;
@ -58,10 +57,10 @@ private:
};
template <class ELFT>
MipsExecutableWriter<ELFT>::MipsExecutableWriter(MipsLinkingContext &context,
MipsExecutableWriter<ELFT>::MipsExecutableWriter(MipsLinkingContext &ctx,
MipsTargetLayout<ELFT> &layout)
: ExecutableWriter<ELFT>(context, layout), _writeHelper(context, layout),
_mipsContext(context), _mipsTargetLayout(layout) {}
: ExecutableWriter<ELFT>(ctx, layout), _writeHelper(ctx, layout),
_mipsContext(ctx), _mipsTargetLayout(layout) {}
template <class ELFT>
void MipsExecutableWriter<ELFT>::buildDynamicSymbolTable(const File &file) {

View File

@ -154,13 +154,13 @@ public:
template <typename ELFT> class RelocationPass : public Pass {
public:
RelocationPass(MipsLinkingContext &context);
RelocationPass(MipsLinkingContext &ctx);
void perform(std::unique_ptr<MutableFile> &mf) override;
private:
/// \brief Reference to the linking context.
const MipsLinkingContext &_context;
const MipsLinkingContext &_ctx;
/// \brief Owner of all the Atoms created by this pass.
RelocationPassFile _file;
@ -259,8 +259,8 @@ private:
};
template <typename ELFT>
RelocationPass<ELFT>::RelocationPass(MipsLinkingContext &context)
: _context(context), _file(context), _gotLDMEntry(nullptr) {
RelocationPass<ELFT>::RelocationPass(MipsLinkingContext &ctx)
: _ctx(ctx), _file(ctx), _gotLDMEntry(nullptr) {
_localGotVector.push_back(new (_file._alloc) GOT0Atom(_file));
_localGotVector.push_back(new (_file._alloc) GOTModulePointerAtom(_file));
}
@ -449,7 +449,7 @@ bool RelocationPass<ELFT>::mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
if ((atom.section()->sh_flags & SHF_ALLOC) == 0)
return false;
if (_context.getOutputELFType() == llvm::ELF::ET_DYN)
if (_ctx.getOutputELFType() == llvm::ELF::ET_DYN)
return true;
if (!isMipsReadonly(atom))
return true;
@ -503,7 +503,7 @@ bool RelocationPass<ELFT>::isDynamic(const Atom *atom) const {
if (sa)
return true;
if (_context.getOutputELFType() == llvm::ELF::ET_DYN) {
if (_ctx.getOutputELFType() == llvm::ELF::ET_DYN) {
if (da && da->scope() != DefinedAtom::scopeTranslationUnit)
return true;
@ -568,7 +568,7 @@ bool RelocationPass<ELFT>::isLocalCall(const Atom *a) const {
return true;
// Calls to external symbols defined in an executable file resolved locally.
if (_context.getOutputELFType() == llvm::ELF::ET_EXEC)
if (_ctx.getOutputELFType() == llvm::ELF::ET_EXEC)
return true;
return false;

View File

@ -18,8 +18,8 @@ class MipsLinkingContext;
/// \brief Handle Mips GOT section
template <class ELFType> class MipsGOTSection : public AtomSection<ELFType> {
public:
MipsGOTSection(const MipsLinkingContext &context)
: AtomSection<ELFType>(context, ".got", DefinedAtom::typeGOT,
MipsGOTSection(const MipsLinkingContext &ctx)
: AtomSection<ELFType>(ctx, ".got", DefinedAtom::typeGOT,
DefinedAtom::permRW_,
MipsTargetLayout<ELFType>::ORDER_GOT),
_hasNonLocal(false), _localCount(0) {
@ -95,8 +95,8 @@ private:
/// \brief Handle Mips PLT section
template <class ELFType> class MipsPLTSection : public AtomSection<ELFType> {
public:
MipsPLTSection(const MipsLinkingContext &context)
: AtomSection<ELFType>(context, ".plt", DefinedAtom::typeGOT,
MipsPLTSection(const MipsLinkingContext &ctx)
: AtomSection<ELFType>(ctx, ".plt", DefinedAtom::typeGOT,
DefinedAtom::permR_X,
MipsTargetLayout<ELFType>::ORDER_PLT) {}

View File

@ -18,22 +18,20 @@ using namespace elf;
typedef llvm::object::ELFType<llvm::support::little, 2, false> Mips32ElELFType;
MipsTargetHandler::MipsTargetHandler(MipsLinkingContext &context)
: DefaultTargetHandler(context), _context(context),
_runtimeFile(new MipsRuntimeFile<Mips32ElELFType>(context)),
_targetLayout(new MipsTargetLayout<Mips32ElELFType>(context)),
MipsTargetHandler::MipsTargetHandler(MipsLinkingContext &ctx)
: DefaultTargetHandler(ctx), _ctx(ctx),
_runtimeFile(new MipsRuntimeFile<Mips32ElELFType>(ctx)),
_targetLayout(new MipsTargetLayout<Mips32ElELFType>(ctx)),
_relocationHandler(new MipsTargetRelocationHandler(*_targetLayout)) {}
std::unique_ptr<Writer> MipsTargetHandler::getWriter() {
switch (_context.getOutputELFType()) {
switch (_ctx.getOutputELFType()) {
case llvm::ELF::ET_EXEC:
return std::unique_ptr<Writer>(
new elf::MipsExecutableWriter<Mips32ElELFType>(_context,
*_targetLayout));
new MipsExecutableWriter<Mips32ElELFType>(_ctx, *_targetLayout));
case llvm::ELF::ET_DYN:
return std::unique_ptr<Writer>(
new elf::MipsDynamicLibraryWriter<Mips32ElELFType>(_context,
*_targetLayout));
new MipsDynamicLibraryWriter<Mips32ElELFType>(_ctx, *_targetLayout));
case llvm::ELF::ET_REL:
llvm_unreachable("TODO: support -r mode");
default:

View File

@ -124,14 +124,14 @@ private:
template <class ELFType>
class MipsRuntimeFile final : public CRuntimeFile<ELFType> {
public:
MipsRuntimeFile(const MipsLinkingContext &context)
: CRuntimeFile<ELFType>(context, "Mips runtime file") {}
MipsRuntimeFile(const MipsLinkingContext &ctx)
: CRuntimeFile<ELFType>(ctx, "Mips runtime file") {}
};
/// \brief TargetHandler for Mips
class MipsTargetHandler final : public DefaultTargetHandler<Mips32ElELFType> {
public:
MipsTargetHandler(MipsLinkingContext &context);
MipsTargetHandler(MipsLinkingContext &ctx);
MipsTargetLayout<Mips32ElELFType> &getTargetLayout() override {
return *_targetLayout;
@ -151,7 +151,7 @@ public:
private:
static const Registry::KindStrings kindStrings[];
MipsLinkingContext &_context;
MipsLinkingContext &_ctx;
std::unique_ptr<MipsRuntimeFile<Mips32ElELFType>> _runtimeFile;
std::unique_ptr<MipsTargetLayout<Mips32ElELFType>> _targetLayout;
std::unique_ptr<MipsTargetRelocationHandler> _relocationHandler;
@ -160,11 +160,10 @@ private:
template <class ELFT>
class MipsDynamicSymbolTable : public DynamicSymbolTable<ELFT> {
public:
MipsDynamicSymbolTable(const MipsLinkingContext &context,
MipsDynamicSymbolTable(const MipsLinkingContext &ctx,
MipsTargetLayout<ELFT> &layout)
: DynamicSymbolTable<ELFT>(
context, layout, ".dynsym",
DefaultLayout<ELFT>::ORDER_DYNAMIC_SYMBOLS),
: DynamicSymbolTable<ELFT>(ctx, layout, ".dynsym",
DefaultLayout<ELFT>::ORDER_DYNAMIC_SYMBOLS),
_targetLayout(layout) {}
void sortSymbols() override {