CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
120 lines
3.9 KiB
C++
120 lines
3.9 KiB
C++
//===-- AVRMCInstLower.cpp - Convert AVR MachineInstr to an MCInst --------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains code to lower AVR MachineInstrs to their corresponding
|
|
// MCInst records.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "AVRMCInstLower.h"
|
|
#include "AVRInstrInfo.h"
|
|
#include "MCTargetDesc/AVRMCAsmInfo.h"
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
|
#include "llvm/IR/Mangler.h"
|
|
#include "llvm/MC/MCInst.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
namespace llvm {
|
|
|
|
MCOperand
|
|
AVRMCInstLower::lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym,
|
|
const AVRSubtarget &Subtarget) const {
|
|
unsigned char TF = MO.getTargetFlags();
|
|
const MCExpr *Expr = MCSymbolRefExpr::create(Sym, Ctx);
|
|
|
|
bool IsNegated = false;
|
|
if (TF & AVRII::MO_NEG) {
|
|
IsNegated = true;
|
|
}
|
|
|
|
if (!MO.isJTI() && MO.getOffset()) {
|
|
Expr = MCBinaryExpr::createAdd(
|
|
Expr, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
|
|
}
|
|
|
|
bool IsFunction = MO.isGlobal() && isa<Function>(MO.getGlobal());
|
|
|
|
if (TF & AVRII::MO_LO) {
|
|
if (IsFunction) {
|
|
Expr = AVRMCExpr::create(Subtarget.hasEIJMPCALL() ? AVR::S_LO8_GS
|
|
: AVR::S_PM_LO8,
|
|
Expr, IsNegated, Ctx);
|
|
} else {
|
|
Expr = AVRMCExpr::create(AVR::S_LO8, Expr, IsNegated, Ctx);
|
|
}
|
|
} else if (TF & AVRII::MO_HI) {
|
|
if (IsFunction) {
|
|
Expr = AVRMCExpr::create(Subtarget.hasEIJMPCALL() ? AVR::S_HI8_GS
|
|
: AVR::S_PM_HI8,
|
|
Expr, IsNegated, Ctx);
|
|
} else {
|
|
Expr = AVRMCExpr::create(AVR::S_HI8, Expr, IsNegated, Ctx);
|
|
}
|
|
} else if (TF != 0) {
|
|
llvm_unreachable("Unknown target flag on symbol operand");
|
|
}
|
|
|
|
return MCOperand::createExpr(Expr);
|
|
}
|
|
|
|
void AVRMCInstLower::lowerInstruction(const MachineInstr &MI,
|
|
MCInst &OutMI) const {
|
|
auto &Subtarget = MI.getParent()->getParent()->getSubtarget<AVRSubtarget>();
|
|
OutMI.setOpcode(MI.getOpcode());
|
|
|
|
for (MachineOperand const &MO : MI.operands()) {
|
|
MCOperand MCOp;
|
|
|
|
switch (MO.getType()) {
|
|
default:
|
|
MI.print(errs());
|
|
llvm_unreachable("unknown operand type");
|
|
case MachineOperand::MO_Register:
|
|
// Ignore all implicit register operands.
|
|
if (MO.isImplicit())
|
|
continue;
|
|
MCOp = MCOperand::createReg(MO.getReg());
|
|
break;
|
|
case MachineOperand::MO_Immediate:
|
|
MCOp = MCOperand::createImm(MO.getImm());
|
|
break;
|
|
case MachineOperand::MO_GlobalAddress:
|
|
MCOp =
|
|
lowerSymbolOperand(MO, Printer.getSymbol(MO.getGlobal()), Subtarget);
|
|
break;
|
|
case MachineOperand::MO_ExternalSymbol:
|
|
MCOp = lowerSymbolOperand(
|
|
MO, Printer.GetExternalSymbolSymbol(MO.getSymbolName()), Subtarget);
|
|
break;
|
|
case MachineOperand::MO_MachineBasicBlock:
|
|
MCOp = MCOperand::createExpr(
|
|
MCSymbolRefExpr::create(MO.getMBB()->getSymbol(), Ctx));
|
|
break;
|
|
case MachineOperand::MO_RegisterMask:
|
|
continue;
|
|
case MachineOperand::MO_BlockAddress:
|
|
MCOp = lowerSymbolOperand(
|
|
MO, Printer.GetBlockAddressSymbol(MO.getBlockAddress()), Subtarget);
|
|
break;
|
|
case MachineOperand::MO_JumpTableIndex:
|
|
MCOp = lowerSymbolOperand(MO, Printer.GetJTISymbol(MO.getIndex()),
|
|
Subtarget);
|
|
break;
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
|
MCOp = lowerSymbolOperand(MO, Printer.GetCPISymbol(MO.getIndex()),
|
|
Subtarget);
|
|
break;
|
|
}
|
|
|
|
OutMI.addOperand(MCOp);
|
|
}
|
|
}
|
|
|
|
} // end of namespace llvm
|