2013-05-06 18:15:19 +02:00
|
|
|
//===-- SystemZAsmPrinter.cpp - SystemZ LLVM assembly printer -------------===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-05-06 18:15:19 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Streams SystemZ assembly language and associated data, in the form of
|
|
|
|
// MCInsts and MCExprs respectively.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SystemZAsmPrinter.h"
|
2019-05-11 05:36:16 +02:00
|
|
|
#include "MCTargetDesc/SystemZInstPrinter.h"
|
2013-05-06 18:15:19 +02:00
|
|
|
#include "SystemZConstantPoolValue.h"
|
|
|
|
#include "SystemZMCInstLower.h"
|
2019-05-15 02:46:18 +02:00
|
|
|
#include "TargetInfo/SystemZTargetInfo.h"
|
2019-12-17 22:13:16 +01:00
|
|
|
#include "llvm/BinaryFormat/ELF.h"
|
2013-05-06 18:15:19 +02:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
|
|
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
2014-01-07 22:19:40 +01:00
|
|
|
#include "llvm/IR/Mangler.h"
|
2013-05-06 18:15:19 +02:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
2013-09-25 12:20:08 +02:00
|
|
|
#include "llvm/MC/MCInstBuilder.h"
|
2019-12-17 22:13:16 +01:00
|
|
|
#include "llvm/MC/MCSectionELF.h"
|
2013-05-06 18:15:19 +02:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2013-09-25 13:11:53 +02:00
|
|
|
// Return an RI instruction like MI with opcode Opcode, but with the
|
|
|
|
// GR64 register operands turned into GR32s.
|
|
|
|
static MCInst lowerRILow(const MachineInstr *MI, unsigned Opcode) {
|
2013-11-22 18:28:28 +01:00
|
|
|
if (MI->isCompare())
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
|
|
|
|
.addImm(MI->getOperand(1).getImm());
|
|
|
|
else
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(SystemZMC::getRegAsGR32(MI->getOperand(1).getReg()))
|
|
|
|
.addImm(MI->getOperand(2).getImm());
|
2013-09-25 13:11:53 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 15:18:56 +02:00
|
|
|
// Return an RI instruction like MI with opcode Opcode, but with the
|
|
|
|
// GR64 register operands turned into GRH32s.
|
|
|
|
static MCInst lowerRIHigh(const MachineInstr *MI, unsigned Opcode) {
|
2013-11-22 18:28:28 +01:00
|
|
|
if (MI->isCompare())
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
|
|
|
|
.addImm(MI->getOperand(1).getImm());
|
|
|
|
else
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(SystemZMC::getRegAsGRH32(MI->getOperand(1).getReg()))
|
|
|
|
.addImm(MI->getOperand(2).getImm());
|
2013-10-01 15:18:56 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 13:26:28 +02:00
|
|
|
// Return an RI instruction like MI with opcode Opcode, but with the
|
|
|
|
// R2 register turned into a GR64.
|
|
|
|
static MCInst lowerRIEfLow(const MachineInstr *MI, unsigned Opcode) {
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addReg(SystemZMC::getRegAsGR64(MI->getOperand(2).getReg()))
|
|
|
|
.addImm(MI->getOperand(3).getImm())
|
|
|
|
.addImm(MI->getOperand(4).getImm())
|
|
|
|
.addImm(MI->getOperand(5).getImm());
|
|
|
|
}
|
|
|
|
|
2015-02-18 10:13:27 +01:00
|
|
|
static const MCSymbolRefExpr *getTLSGetOffset(MCContext &Context) {
|
|
|
|
StringRef Name = "__tls_get_offset";
|
2015-05-30 03:25:56 +02:00
|
|
|
return MCSymbolRefExpr::create(Context.getOrCreateSymbol(Name),
|
2015-02-18 10:13:27 +01:00
|
|
|
MCSymbolRefExpr::VK_PLT,
|
|
|
|
Context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MCSymbolRefExpr *getGlobalOffsetTable(MCContext &Context) {
|
|
|
|
StringRef Name = "_GLOBAL_OFFSET_TABLE_";
|
2015-05-30 03:25:56 +02:00
|
|
|
return MCSymbolRefExpr::create(Context.getOrCreateSymbol(Name),
|
2015-02-18 10:13:27 +01:00
|
|
|
MCSymbolRefExpr::VK_None,
|
|
|
|
Context);
|
|
|
|
}
|
|
|
|
|
2019-06-19 16:20:00 +02:00
|
|
|
// MI is an instruction that accepts an optional alignment hint,
|
|
|
|
// and which was already lowered to LoweredMI. If the alignment
|
|
|
|
// of the original memory operand is known, update LoweredMI to
|
|
|
|
// an instruction with the corresponding hint set.
|
|
|
|
static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI,
|
|
|
|
unsigned Opcode) {
|
|
|
|
if (!MI->hasOneMemOperand())
|
|
|
|
return;
|
|
|
|
const MachineMemOperand *MMO = *MI->memoperands_begin();
|
|
|
|
unsigned AlignmentHint = 0;
|
[Alignment][NFC] MachineMemOperand::getAlign/getBaseAlign
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: arsenm, dschuff, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, jrtc27, atanasyan, jfb, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76925
2020-03-27 14:51:59 +01:00
|
|
|
if (MMO->getAlign() >= Align(16))
|
2019-06-19 16:20:00 +02:00
|
|
|
AlignmentHint = 4;
|
[Alignment][NFC] MachineMemOperand::getAlign/getBaseAlign
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: arsenm, dschuff, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, jrtc27, atanasyan, jfb, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76925
2020-03-27 14:51:59 +01:00
|
|
|
else if (MMO->getAlign() >= Align(8))
|
2019-06-19 16:20:00 +02:00
|
|
|
AlignmentHint = 3;
|
|
|
|
if (AlignmentHint == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LoweredMI.setOpcode(Opcode);
|
|
|
|
LoweredMI.addOperand(MCOperand::createImm(AlignmentHint));
|
|
|
|
}
|
|
|
|
|
2015-05-05 21:28:34 +02:00
|
|
|
// MI loads the high part of a vector from memory. Return an instruction
|
|
|
|
// that uses replicating vector load Opcode to do the same thing.
|
|
|
|
static MCInst lowerSubvectorLoad(const MachineInstr *MI, unsigned Opcode) {
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(MI->getOperand(3).getReg());
|
|
|
|
}
|
|
|
|
|
|
|
|
// MI stores the high part of a vector to memory. Return an instruction
|
|
|
|
// that uses elemental vector store Opcode to do the same thing.
|
|
|
|
static MCInst lowerSubvectorStore(const MachineInstr *MI, unsigned Opcode) {
|
|
|
|
return MCInstBuilder(Opcode)
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(MI->getOperand(3).getReg())
|
|
|
|
.addImm(0);
|
|
|
|
}
|
|
|
|
|
2020-02-14 06:58:16 +01:00
|
|
|
void SystemZAsmPrinter::emitInstruction(const MachineInstr *MI) {
|
2013-10-29 17:18:15 +01:00
|
|
|
SystemZMCInstLower Lower(MF->getContext(), *this);
|
2021-02-19 23:44:10 +01:00
|
|
|
const SystemZSubtarget *Subtarget = &MF->getSubtarget<SystemZSubtarget>();
|
2013-05-06 18:15:19 +02:00
|
|
|
MCInst LoweredMI;
|
2013-09-25 12:20:08 +02:00
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
case SystemZ::Return:
|
2021-02-19 23:44:10 +01:00
|
|
|
if (Subtarget->isTargetXPLINK64())
|
|
|
|
LoweredMI =
|
|
|
|
MCInstBuilder(SystemZ::B).addReg(SystemZ::R7D).addImm(2).addReg(0);
|
|
|
|
else
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D);
|
2013-09-25 12:20:08 +02:00
|
|
|
break;
|
|
|
|
|
2016-04-07 18:11:44 +02:00
|
|
|
case SystemZ::CondReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BCR)
|
|
|
|
.addImm(MI->getOperand(0).getImm())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addReg(SystemZ::R14D);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CRBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CGRBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CGRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CIBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CGIBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CGIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLRBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLGRBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLGRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLIBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLGIBReturn:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLGIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
2021-02-19 23:44:10 +01:00
|
|
|
case SystemZ::CallBRASL_XPLINK64:
|
|
|
|
EmitToStreamer(*OutStreamer,
|
|
|
|
MCInstBuilder(SystemZ::BRASL)
|
|
|
|
.addReg(SystemZ::R7D)
|
|
|
|
.addExpr(Lower.getExpr(MI->getOperand(0),
|
|
|
|
MCSymbolRefExpr::VK_PLT)));
|
|
|
|
EmitToStreamer(
|
|
|
|
*OutStreamer,
|
|
|
|
MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R3D));
|
|
|
|
return;
|
|
|
|
|
|
|
|
case SystemZ::CallBASR_XPLINK64:
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BASR)
|
|
|
|
.addReg(SystemZ::R7D)
|
|
|
|
.addReg(MI->getOperand(0).getReg()));
|
|
|
|
EmitToStreamer(
|
|
|
|
*OutStreamer,
|
|
|
|
MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D));
|
|
|
|
return;
|
|
|
|
|
2013-09-25 12:37:17 +02:00
|
|
|
case SystemZ::CallBRASL:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BRASL)
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addExpr(Lower.getExpr(MI->getOperand(0), MCSymbolRefExpr::VK_PLT));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CallBASR:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BASR)
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addReg(MI->getOperand(0).getReg());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CallJG:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::JG)
|
|
|
|
.addExpr(Lower.getExpr(MI->getOperand(0), MCSymbolRefExpr::VK_PLT));
|
|
|
|
break;
|
|
|
|
|
2016-04-08 19:22:19 +02:00
|
|
|
case SystemZ::CallBRCL:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BRCL)
|
|
|
|
.addImm(MI->getOperand(0).getImm())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addExpr(Lower.getExpr(MI->getOperand(2), MCSymbolRefExpr::VK_PLT));
|
|
|
|
break;
|
|
|
|
|
2013-09-25 12:37:17 +02:00
|
|
|
case SystemZ::CallBR:
|
2020-12-15 16:18:43 +01:00
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BR)
|
|
|
|
.addReg(MI->getOperand(0).getReg());
|
2013-09-25 12:37:17 +02:00
|
|
|
break;
|
|
|
|
|
2016-04-11 14:12:32 +02:00
|
|
|
case SystemZ::CallBCR:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BCR)
|
|
|
|
.addImm(MI->getOperand(0).getImm())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(2).getReg());
|
2016-04-11 14:12:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CRBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CGRBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CGRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CIBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CGIBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CGIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLRBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLGRBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLGRB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLIBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::CLGIBCall:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::CLGIB)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addImm(MI->getOperand(2).getImm())
|
2020-12-15 16:18:43 +01:00
|
|
|
.addReg(MI->getOperand(3).getReg())
|
2016-04-11 14:12:32 +02:00
|
|
|
.addImm(0);
|
|
|
|
break;
|
|
|
|
|
2015-02-18 10:13:27 +01:00
|
|
|
case SystemZ::TLS_GDCALL:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BRASL)
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addExpr(getTLSGetOffset(MF->getContext()))
|
|
|
|
.addExpr(Lower.getExpr(MI->getOperand(0), MCSymbolRefExpr::VK_TLSGD));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::TLS_LDCALL:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BRASL)
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addExpr(getTLSGetOffset(MF->getContext()))
|
|
|
|
.addExpr(Lower.getExpr(MI->getOperand(0), MCSymbolRefExpr::VK_TLSLDM));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::GOT:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::LARL)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addExpr(getGlobalOffsetTable(MF->getContext()));
|
|
|
|
break;
|
|
|
|
|
2013-09-25 13:11:53 +02:00
|
|
|
case SystemZ::IILF64:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::IILF)
|
|
|
|
.addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
|
|
|
|
.addImm(MI->getOperand(2).getImm());
|
|
|
|
break;
|
|
|
|
|
2013-10-01 15:02:28 +02:00
|
|
|
case SystemZ::IIHF64:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::IIHF)
|
|
|
|
.addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
|
|
|
|
.addImm(MI->getOperand(2).getImm());
|
|
|
|
break;
|
|
|
|
|
2013-10-01 13:26:28 +02:00
|
|
|
case SystemZ::RISBHH:
|
|
|
|
case SystemZ::RISBHL:
|
|
|
|
LoweredMI = lowerRIEfLow(MI, SystemZ::RISBHG);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::RISBLH:
|
|
|
|
case SystemZ::RISBLL:
|
|
|
|
LoweredMI = lowerRIEfLow(MI, SystemZ::RISBLG);
|
|
|
|
break;
|
|
|
|
|
[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-05 21:25:42 +02:00
|
|
|
case SystemZ::VLVGP32:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::VLVGP)
|
|
|
|
.addReg(MI->getOperand(0).getReg())
|
|
|
|
.addReg(SystemZMC::getRegAsGR64(MI->getOperand(1).getReg()))
|
|
|
|
.addReg(SystemZMC::getRegAsGR64(MI->getOperand(2).getReg()));
|
|
|
|
break;
|
|
|
|
|
2015-05-05 21:28:34 +02:00
|
|
|
case SystemZ::VLR32:
|
|
|
|
case SystemZ::VLR64:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::VLR)
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg()));
|
|
|
|
break;
|
|
|
|
|
2019-06-19 16:20:00 +02:00
|
|
|
case SystemZ::VL:
|
|
|
|
Lower.lower(MI, LoweredMI);
|
|
|
|
lowerAlignmentHint(MI, LoweredMI, SystemZ::VLAlign);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::VST:
|
|
|
|
Lower.lower(MI, LoweredMI);
|
|
|
|
lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTAlign);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::VLM:
|
|
|
|
Lower.lower(MI, LoweredMI);
|
|
|
|
lowerAlignmentHint(MI, LoweredMI, SystemZ::VLMAlign);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::VSTM:
|
|
|
|
Lower.lower(MI, LoweredMI);
|
|
|
|
lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTMAlign);
|
|
|
|
break;
|
|
|
|
|
2015-05-05 21:28:34 +02:00
|
|
|
case SystemZ::VL32:
|
|
|
|
LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPF);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::VL64:
|
|
|
|
LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPG);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::VST32:
|
|
|
|
LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEF);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::VST64:
|
|
|
|
LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEG);
|
|
|
|
break;
|
|
|
|
|
2015-05-05 21:27:45 +02:00
|
|
|
case SystemZ::LFER:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::VLGVF)
|
|
|
|
.addReg(SystemZMC::getRegAsGR64(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg()))
|
|
|
|
.addReg(0).addImm(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SystemZ::LEFR:
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::VLVGF)
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
|
|
|
|
.addReg(MI->getOperand(1).getReg())
|
|
|
|
.addReg(0).addImm(0);
|
|
|
|
break;
|
|
|
|
|
2013-09-25 13:11:53 +02:00
|
|
|
#define LOWER_LOW(NAME) \
|
|
|
|
case SystemZ::NAME##64: LoweredMI = lowerRILow(MI, SystemZ::NAME); break
|
|
|
|
|
|
|
|
LOWER_LOW(IILL);
|
|
|
|
LOWER_LOW(IILH);
|
2013-11-22 18:28:28 +01:00
|
|
|
LOWER_LOW(TMLL);
|
|
|
|
LOWER_LOW(TMLH);
|
2013-09-25 13:11:53 +02:00
|
|
|
LOWER_LOW(NILL);
|
|
|
|
LOWER_LOW(NILH);
|
|
|
|
LOWER_LOW(NILF);
|
|
|
|
LOWER_LOW(OILL);
|
|
|
|
LOWER_LOW(OILH);
|
|
|
|
LOWER_LOW(OILF);
|
|
|
|
LOWER_LOW(XILF);
|
|
|
|
|
|
|
|
#undef LOWER_LOW
|
|
|
|
|
2013-10-01 15:18:56 +02:00
|
|
|
#define LOWER_HIGH(NAME) \
|
|
|
|
case SystemZ::NAME##64: LoweredMI = lowerRIHigh(MI, SystemZ::NAME); break
|
|
|
|
|
|
|
|
LOWER_HIGH(IIHL);
|
|
|
|
LOWER_HIGH(IIHH);
|
2013-11-22 18:28:28 +01:00
|
|
|
LOWER_HIGH(TMHL);
|
|
|
|
LOWER_HIGH(TMHH);
|
2013-10-01 16:20:41 +02:00
|
|
|
LOWER_HIGH(NIHL);
|
|
|
|
LOWER_HIGH(NIHH);
|
|
|
|
LOWER_HIGH(NIHF);
|
2013-10-01 15:22:41 +02:00
|
|
|
LOWER_HIGH(OIHL);
|
|
|
|
LOWER_HIGH(OIHH);
|
|
|
|
LOWER_HIGH(OIHF);
|
2013-10-01 16:08:44 +02:00
|
|
|
LOWER_HIGH(XIHF);
|
2013-10-01 15:18:56 +02:00
|
|
|
|
|
|
|
#undef LOWER_HIGH
|
|
|
|
|
2013-12-10 11:36:34 +01:00
|
|
|
case SystemZ::Serialize:
|
2015-02-19 02:26:28 +01:00
|
|
|
if (MF->getSubtarget<SystemZSubtarget>().hasFastSerialization())
|
2016-11-08 19:30:50 +01:00
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BCRAsm)
|
2013-12-10 11:36:34 +01:00
|
|
|
.addImm(14).addReg(SystemZ::R0D);
|
|
|
|
else
|
2016-11-08 19:30:50 +01:00
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BCRAsm)
|
2013-12-10 11:36:34 +01:00
|
|
|
.addImm(15).addReg(SystemZ::R0D);
|
|
|
|
break;
|
|
|
|
|
2016-04-04 14:45:44 +02:00
|
|
|
// Emit nothing here but a comment if we can.
|
|
|
|
case SystemZ::MemBarrier:
|
|
|
|
OutStreamer->emitRawComment("MEMBARRIER");
|
|
|
|
return;
|
|
|
|
|
2016-06-10 21:58:10 +02:00
|
|
|
// We want to emit "j .+2" for traps, jumping to the relative immediate field
|
|
|
|
// of the jump instruction, which is an illegal instruction. We cannot emit a
|
|
|
|
// "." symbol, so create and emit a temp label before the instruction and use
|
|
|
|
// that instead.
|
|
|
|
case SystemZ::Trap: {
|
|
|
|
MCSymbol *DotSym = OutContext.createTempSymbol();
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer->emitLabel(DotSym);
|
2016-06-10 21:58:10 +02:00
|
|
|
|
|
|
|
const MCSymbolRefExpr *Expr = MCSymbolRefExpr::create(DotSym, OutContext);
|
|
|
|
const MCConstantExpr *ConstExpr = MCConstantExpr::create(2, OutContext);
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::J)
|
|
|
|
.addExpr(MCBinaryExpr::createAdd(Expr, ConstExpr, OutContext));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Conditional traps will create a branch on condition instruction that jumps
|
|
|
|
// to the relative immediate field of the jump instruction. (eg. "jo .+2")
|
|
|
|
case SystemZ::CondTrap: {
|
|
|
|
MCSymbol *DotSym = OutContext.createTempSymbol();
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer->emitLabel(DotSym);
|
2016-06-10 21:58:10 +02:00
|
|
|
|
|
|
|
const MCSymbolRefExpr *Expr = MCSymbolRefExpr::create(DotSym, OutContext);
|
|
|
|
const MCConstantExpr *ConstExpr = MCConstantExpr::create(2, OutContext);
|
|
|
|
LoweredMI = MCInstBuilder(SystemZ::BRC)
|
|
|
|
.addImm(MI->getOperand(0).getImm())
|
|
|
|
.addImm(MI->getOperand(1).getImm())
|
|
|
|
.addExpr(MCBinaryExpr::createAdd(Expr, ConstExpr, OutContext));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2019-09-03 13:21:12 +02:00
|
|
|
case TargetOpcode::FENTRY_CALL:
|
|
|
|
LowerFENTRY_CALL(*MI, Lower);
|
|
|
|
return;
|
|
|
|
|
2018-03-02 21:39:30 +01:00
|
|
|
case TargetOpcode::STACKMAP:
|
|
|
|
LowerSTACKMAP(*MI);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TargetOpcode::PATCHPOINT:
|
|
|
|
LowerPATCHPOINT(*MI, Lower);
|
|
|
|
return;
|
|
|
|
|
2021-06-05 02:32:03 +02:00
|
|
|
case SystemZ::EXRL_Pseudo: {
|
|
|
|
unsigned TargetInsOpc = MI->getOperand(0).getImm();
|
|
|
|
Register LenMinus1Reg = MI->getOperand(1).getReg();
|
|
|
|
Register DestReg = MI->getOperand(2).getReg();
|
|
|
|
int64_t DestDisp = MI->getOperand(3).getImm();
|
|
|
|
Register SrcReg = MI->getOperand(4).getReg();
|
|
|
|
int64_t SrcDisp = MI->getOperand(5).getImm();
|
|
|
|
|
|
|
|
MCSymbol *DotSym = nullptr;
|
|
|
|
MCInst ET = MCInstBuilder(TargetInsOpc).addReg(DestReg)
|
|
|
|
.addImm(DestDisp).addImm(1).addReg(SrcReg).addImm(SrcDisp);
|
|
|
|
MCInstSTIPair ET_STI(ET, &MF->getSubtarget());
|
|
|
|
EXRLT2SymMap::iterator I = EXRLTargets2Sym.find(ET_STI);
|
|
|
|
if (I != EXRLTargets2Sym.end())
|
|
|
|
DotSym = I->second;
|
|
|
|
else
|
|
|
|
EXRLTargets2Sym[ET_STI] = DotSym = OutContext.createTempSymbol();
|
|
|
|
const MCSymbolRefExpr *Dot = MCSymbolRefExpr::create(DotSym, OutContext);
|
|
|
|
EmitToStreamer(
|
|
|
|
*OutStreamer,
|
|
|
|
MCInstBuilder(SystemZ::EXRL).addReg(LenMinus1Reg).addExpr(Dot));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-25 12:20:08 +02:00
|
|
|
default:
|
2013-09-25 12:37:17 +02:00
|
|
|
Lower.lower(MI, LoweredMI);
|
2013-09-25 12:20:08 +02:00
|
|
|
break;
|
|
|
|
}
|
2015-04-24 21:11:51 +02:00
|
|
|
EmitToStreamer(*OutStreamer, LoweredMI);
|
2013-05-06 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2018-03-02 21:39:30 +01:00
|
|
|
// Emit the largest nop instruction smaller than or equal to NumBytes
|
|
|
|
// bytes. Return the size of nop emitted.
|
|
|
|
static unsigned EmitNop(MCContext &OutContext, MCStreamer &OutStreamer,
|
|
|
|
unsigned NumBytes, const MCSubtargetInfo &STI) {
|
|
|
|
if (NumBytes < 2) {
|
|
|
|
llvm_unreachable("Zero nops?");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (NumBytes < 4) {
|
2020-02-14 06:58:16 +01:00
|
|
|
OutStreamer.emitInstruction(
|
|
|
|
MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D), STI);
|
2018-03-02 21:39:30 +01:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else if (NumBytes < 6) {
|
2020-02-14 06:58:16 +01:00
|
|
|
OutStreamer.emitInstruction(
|
|
|
|
MCInstBuilder(SystemZ::BCAsm).addImm(0).addReg(0).addImm(0).addReg(0),
|
|
|
|
STI);
|
2018-03-02 21:39:30 +01:00
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
MCSymbol *DotSym = OutContext.createTempSymbol();
|
|
|
|
const MCSymbolRefExpr *Dot = MCSymbolRefExpr::create(DotSym, OutContext);
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer.emitLabel(DotSym);
|
2020-02-14 06:58:16 +01:00
|
|
|
OutStreamer.emitInstruction(
|
|
|
|
MCInstBuilder(SystemZ::BRCLAsm).addImm(0).addExpr(Dot), STI);
|
2018-03-02 21:39:30 +01:00
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 13:21:12 +02:00
|
|
|
void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
|
|
|
|
SystemZMCInstLower &Lower) {
|
|
|
|
MCContext &Ctx = MF->getContext();
|
2019-12-17 22:13:16 +01:00
|
|
|
if (MF->getFunction().hasFnAttribute("mrecord-mcount")) {
|
|
|
|
MCSymbol *DotSym = OutContext.createTempSymbol();
|
|
|
|
OutStreamer->PushSection();
|
|
|
|
OutStreamer->SwitchSection(
|
|
|
|
Ctx.getELFSection("__mcount_loc", ELF::SHT_PROGBITS, ELF::SHF_ALLOC));
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer->emitSymbolValue(DotSym, 8);
|
2019-12-17 22:13:16 +01:00
|
|
|
OutStreamer->PopSection();
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer->emitLabel(DotSym);
|
2019-12-17 22:13:16 +01:00
|
|
|
}
|
|
|
|
|
2019-12-18 19:12:41 +01:00
|
|
|
if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
|
2019-09-26 10:38:07 +02:00
|
|
|
EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-03 13:21:12 +02:00
|
|
|
MCSymbol *fentry = Ctx.getOrCreateSymbol("__fentry__");
|
|
|
|
const MCSymbolRefExpr *Op =
|
|
|
|
MCSymbolRefExpr::create(fentry, MCSymbolRefExpr::VK_PLT, Ctx);
|
2020-02-14 06:58:16 +01:00
|
|
|
OutStreamer->emitInstruction(
|
|
|
|
MCInstBuilder(SystemZ::BRASL).addReg(SystemZ::R0D).addExpr(Op),
|
|
|
|
getSubtargetInfo());
|
2019-09-03 13:21:12 +02:00
|
|
|
}
|
|
|
|
|
2018-03-02 21:39:30 +01:00
|
|
|
void SystemZAsmPrinter::LowerSTACKMAP(const MachineInstr &MI) {
|
|
|
|
const SystemZInstrInfo *TII =
|
|
|
|
static_cast<const SystemZInstrInfo *>(MF->getSubtarget().getInstrInfo());
|
|
|
|
|
|
|
|
unsigned NumNOPBytes = MI.getOperand(1).getImm();
|
|
|
|
|
2019-12-19 23:03:19 +01:00
|
|
|
auto &Ctx = OutStreamer->getContext();
|
|
|
|
MCSymbol *MILabel = Ctx.createTempSymbol();
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer->emitLabel(MILabel);
|
2019-12-19 23:03:19 +01:00
|
|
|
|
|
|
|
SM.recordStackMap(*MILabel, MI);
|
2018-03-02 21:39:30 +01:00
|
|
|
assert(NumNOPBytes % 2 == 0 && "Invalid number of NOP bytes requested!");
|
|
|
|
|
|
|
|
// Scan ahead to trim the shadow.
|
|
|
|
unsigned ShadowBytes = 0;
|
|
|
|
const MachineBasicBlock &MBB = *MI.getParent();
|
|
|
|
MachineBasicBlock::const_iterator MII(MI);
|
|
|
|
++MII;
|
|
|
|
while (ShadowBytes < NumNOPBytes) {
|
|
|
|
if (MII == MBB.end() ||
|
|
|
|
MII->getOpcode() == TargetOpcode::PATCHPOINT ||
|
|
|
|
MII->getOpcode() == TargetOpcode::STACKMAP)
|
|
|
|
break;
|
|
|
|
ShadowBytes += TII->getInstSizeInBytes(*MII);
|
|
|
|
if (MII->isCall())
|
|
|
|
break;
|
|
|
|
++MII;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit nops.
|
|
|
|
while (ShadowBytes < NumNOPBytes)
|
|
|
|
ShadowBytes += EmitNop(OutContext, *OutStreamer, NumNOPBytes - ShadowBytes,
|
|
|
|
getSubtargetInfo());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lower a patchpoint of the form:
|
|
|
|
// [<def>], <id>, <numBytes>, <target>, <numArgs>
|
|
|
|
void SystemZAsmPrinter::LowerPATCHPOINT(const MachineInstr &MI,
|
|
|
|
SystemZMCInstLower &Lower) {
|
2019-12-19 23:03:19 +01:00
|
|
|
auto &Ctx = OutStreamer->getContext();
|
|
|
|
MCSymbol *MILabel = Ctx.createTempSymbol();
|
2020-02-15 04:21:58 +01:00
|
|
|
OutStreamer->emitLabel(MILabel);
|
2019-12-19 23:03:19 +01:00
|
|
|
|
|
|
|
SM.recordPatchPoint(*MILabel, MI);
|
2018-03-02 21:39:30 +01:00
|
|
|
PatchPointOpers Opers(&MI);
|
|
|
|
|
|
|
|
unsigned EncodedBytes = 0;
|
|
|
|
const MachineOperand &CalleeMO = Opers.getCallTarget();
|
|
|
|
|
|
|
|
if (CalleeMO.isImm()) {
|
|
|
|
uint64_t CallTarget = CalleeMO.getImm();
|
|
|
|
if (CallTarget) {
|
|
|
|
unsigned ScratchIdx = -1;
|
|
|
|
unsigned ScratchReg = 0;
|
|
|
|
do {
|
|
|
|
ScratchIdx = Opers.getNextScratchIdx(ScratchIdx + 1);
|
|
|
|
ScratchReg = MI.getOperand(ScratchIdx).getReg();
|
|
|
|
} while (ScratchReg == SystemZ::R0D);
|
|
|
|
|
|
|
|
// Materialize the call target address
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::LLILF)
|
|
|
|
.addReg(ScratchReg)
|
|
|
|
.addImm(CallTarget & 0xFFFFFFFF));
|
|
|
|
EncodedBytes += 6;
|
|
|
|
if (CallTarget >> 32) {
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::IIHF)
|
|
|
|
.addReg(ScratchReg)
|
|
|
|
.addImm(CallTarget >> 32));
|
|
|
|
EncodedBytes += 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BASR)
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addReg(ScratchReg));
|
|
|
|
EncodedBytes += 2;
|
|
|
|
}
|
|
|
|
} else if (CalleeMO.isGlobal()) {
|
|
|
|
const MCExpr *Expr = Lower.getExpr(CalleeMO, MCSymbolRefExpr::VK_PLT);
|
|
|
|
EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRASL)
|
|
|
|
.addReg(SystemZ::R14D)
|
|
|
|
.addExpr(Expr));
|
|
|
|
EncodedBytes += 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit padding.
|
|
|
|
unsigned NumBytes = Opers.getNumPatchBytes();
|
|
|
|
assert(NumBytes >= EncodedBytes &&
|
|
|
|
"Patchpoint can't request size less than the length of a call.");
|
|
|
|
assert((NumBytes - EncodedBytes) % 2 == 0 &&
|
|
|
|
"Invalid number of NOP bytes requested!");
|
|
|
|
while (EncodedBytes < NumBytes)
|
|
|
|
EncodedBytes += EmitNop(OutContext, *OutStreamer, NumBytes - EncodedBytes,
|
|
|
|
getSubtargetInfo());
|
|
|
|
}
|
|
|
|
|
2021-06-05 02:32:03 +02:00
|
|
|
void SystemZAsmPrinter::emitEXRLTargetInstructions() {
|
|
|
|
if (EXRLTargets2Sym.empty())
|
|
|
|
return;
|
|
|
|
// Switch to the .text section.
|
|
|
|
OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
|
|
|
|
for (auto &I : EXRLTargets2Sym) {
|
|
|
|
OutStreamer->emitLabel(I.second);
|
|
|
|
const MCInstSTIPair &MCI_STI = I.first;
|
|
|
|
OutStreamer->emitInstruction(MCI_STI.first, *MCI_STI.second);
|
|
|
|
}
|
|
|
|
EXRLTargets2Sym.clear();
|
|
|
|
}
|
|
|
|
|
2013-05-06 18:15:19 +02:00
|
|
|
// Convert a SystemZ-specific constant pool modifier into the associated
|
|
|
|
// MCSymbolRefExpr variant kind.
|
|
|
|
static MCSymbolRefExpr::VariantKind
|
|
|
|
getModifierVariantKind(SystemZCP::SystemZCPModifier Modifier) {
|
|
|
|
switch (Modifier) {
|
2015-02-18 10:13:27 +01:00
|
|
|
case SystemZCP::TLSGD: return MCSymbolRefExpr::VK_TLSGD;
|
|
|
|
case SystemZCP::TLSLDM: return MCSymbolRefExpr::VK_TLSLDM;
|
|
|
|
case SystemZCP::DTPOFF: return MCSymbolRefExpr::VK_DTPOFF;
|
2013-05-06 18:15:19 +02:00
|
|
|
case SystemZCP::NTPOFF: return MCSymbolRefExpr::VK_NTPOFF;
|
|
|
|
}
|
|
|
|
llvm_unreachable("Invalid SystemCPModifier!");
|
|
|
|
}
|
|
|
|
|
2020-02-14 01:36:27 +01:00
|
|
|
void SystemZAsmPrinter::emitMachineConstantPoolValue(
|
|
|
|
MachineConstantPoolValue *MCPV) {
|
2014-03-06 12:22:58 +01:00
|
|
|
auto *ZCPV = static_cast<SystemZConstantPoolValue*>(MCPV);
|
2013-05-06 18:15:19 +02:00
|
|
|
|
|
|
|
const MCExpr *Expr =
|
2015-05-30 03:25:56 +02:00
|
|
|
MCSymbolRefExpr::create(getSymbol(ZCPV->getGlobalValue()),
|
2013-05-06 18:15:19 +02:00
|
|
|
getModifierVariantKind(ZCPV->getModifier()),
|
|
|
|
OutContext);
|
2015-07-16 08:11:10 +02:00
|
|
|
uint64_t Size = getDataLayout().getTypeAllocSize(ZCPV->getType());
|
2013-05-06 18:15:19 +02:00
|
|
|
|
2020-02-15 07:40:47 +01:00
|
|
|
OutStreamer->emitValue(Expr, Size);
|
2013-05-06 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
[AsmPrinter] refactor to remove remove AsmVariant. NFC
Summary:
The InlineAsm::AsmDialect is only required for X86; no architecture
makes use of it and as such it gets passed around between arch-specific
and general code while being unused for all architectures but X86.
Since the AsmDialect is queried from a MachineInstr, which we also pass
around, remove the additional AsmDialect parameter and query for it deep
in the X86AsmPrinter only when needed/as late as possible.
This refactor should help later planned refactors to AsmPrinter, as this
difference in the X86AsmPrinter makes it harder to make AsmPrinter more
generic.
Reviewers: craig.topper
Subscribers: jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, sbc100, jgravelle-google, eraman, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, llvm-commits, peter.smith, srhines
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60488
llvm-svn: 358101
2019-04-10 18:38:43 +02:00
|
|
|
bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
2013-05-06 18:15:19 +02:00
|
|
|
const char *ExtraCode,
|
|
|
|
raw_ostream &OS) {
|
2021-07-06 19:14:47 +02:00
|
|
|
const MCRegisterInfo &MRI = *TM.getMCRegisterInfo();
|
2021-07-10 11:15:12 +02:00
|
|
|
const MachineOperand &MO = MI->getOperand(OpNo);
|
|
|
|
MCOperand MCOp;
|
2021-07-06 19:14:47 +02:00
|
|
|
if (ExtraCode) {
|
|
|
|
if (ExtraCode[0] == 'N' && !ExtraCode[1] && MO.isReg() &&
|
|
|
|
SystemZ::GR128BitRegClass.contains(MO.getReg()))
|
2021-07-10 11:15:12 +02:00
|
|
|
MCOp =
|
|
|
|
MCOperand::createReg(MRI.getSubReg(MO.getReg(), SystemZ::subreg_l64));
|
2021-07-06 19:14:47 +02:00
|
|
|
else
|
|
|
|
return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS);
|
2021-07-10 11:15:12 +02:00
|
|
|
} else {
|
|
|
|
SystemZMCInstLower Lower(MF->getContext(), *this);
|
|
|
|
MCOp = Lower.lowerOperand(MO);
|
2021-07-06 19:14:47 +02:00
|
|
|
}
|
|
|
|
SystemZInstPrinter::printOperand(MCOp, MAI, OS);
|
2013-05-06 18:15:19 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemZAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
|
|
|
unsigned OpNo,
|
|
|
|
const char *ExtraCode,
|
|
|
|
raw_ostream &OS) {
|
2021-04-27 19:37:16 +02:00
|
|
|
SystemZInstPrinter::printAddress(MAI, MI->getOperand(OpNo).getReg(),
|
2013-05-06 18:15:19 +02:00
|
|
|
MI->getOperand(OpNo + 1).getImm(),
|
|
|
|
MI->getOperand(OpNo + 2).getReg(), OS);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-13 22:10:49 +01:00
|
|
|
void SystemZAsmPrinter::emitEndOfAsmFile(Module &M) {
|
2021-06-05 02:32:03 +02:00
|
|
|
emitEXRLTargetInstructions();
|
2018-11-26 19:43:48 +01:00
|
|
|
emitStackMaps(SM);
|
2018-03-02 21:39:30 +01:00
|
|
|
}
|
|
|
|
|
2013-05-06 18:15:19 +02:00
|
|
|
// Force static initialization.
|
CMake: Make most target symbols hidden by default
Summary:
For builds with LLVM_BUILD_LLVM_DYLIB=ON and BUILD_SHARED_LIBS=OFF
this change makes all symbols in the target specific libraries hidden
by default.
A new macro called LLVM_EXTERNAL_VISIBILITY has been added to mark symbols in these
libraries public, which is mainly needed for the definitions of the
LLVMInitialize* functions.
This patch reduces the number of public symbols in libLLVM.so by about
25%. This should improve load times for the dynamic library and also
make abi checker tools, like abidiff require less memory when analyzing
libLLVM.so
One side-effect of this change is that for builds with
LLVM_BUILD_LLVM_DYLIB=ON and LLVM_LINK_LLVM_DYLIB=ON some unittests that
access symbols that are no longer public will need to be statically linked.
Before and after public symbol counts (using gcc 8.2.1, ld.bfd 2.31.1):
nm before/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l
36221
nm after/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l
26278
Reviewers: chandlerc, beanz, mgorny, rnk, hans
Reviewed By: rnk, hans
Subscribers: merge_guards_bot, luismarques, smeenai, ldionne, lenary, s.egerton, pzheng, sameer.abuasal, MaskRay, wuzish, echristo, Jim, hiraditya, michaelplatings, chapuni, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, mgrang, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, kristina, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D54439
2020-01-15 04:15:07 +01:00
|
|
|
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmPrinter() {
|
2016-10-10 01:00:34 +02:00
|
|
|
RegisterAsmPrinter<SystemZAsmPrinter> X(getTheSystemZTarget());
|
2013-05-06 18:15:19 +02:00
|
|
|
}
|