2002-11-18 05:03:35 +08:00
|
|
|
//===-- X86InstrBuilder.h - Functions to aid building x86 insts -*- C++ -*-===//
|
2005-04-22 07:38:14 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08: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
|
2005-04-22 07:38:14 +08:00
|
|
|
//
|
2003-10-21 23:17:13 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-11-18 05:03:35 +08:00
|
|
|
//
|
|
|
|
// This file exposes functions that may be used with BuildMI from the
|
|
|
|
// MachineInstrBuilder.h file to handle X86'isms in a clean way.
|
|
|
|
//
|
|
|
|
// The BuildMem function may be used with the BuildMI function to add entire
|
|
|
|
// memory references in a single, typed, function call. X86 memory references
|
|
|
|
// can be very complex expressions (described in the README), so wrapping them
|
|
|
|
// up behind an easier to use interface makes sense. Descriptions of the
|
|
|
|
// functions are included below.
|
|
|
|
//
|
2002-12-13 17:28:50 +08:00
|
|
|
// For reference, the order of operands for memory references is:
|
|
|
|
// (Operand), Base, Scale, Index, Displacement.
|
|
|
|
//
|
2002-11-18 05:03:35 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_X86_X86INSTRBUILDER_H
|
|
|
|
#define LLVM_LIB_TARGET_X86_X86INSTRBUILDER_H
|
2002-11-18 05:03:35 +08:00
|
|
|
|
2016-08-19 01:56:27 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2008-12-04 02:11:40 +08:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2016-08-19 01:56:27 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2002-11-18 05:03:35 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2009-09-26 04:36:54 +08:00
|
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
2016-08-19 01:56:27 +08:00
|
|
|
#include "llvm/CodeGen/MachineOperand.h"
|
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
|
|
|
#include <cassert>
|
2002-11-18 05:03:35 +08:00
|
|
|
|
2003-11-12 06:41:34 +08:00
|
|
|
namespace llvm {
|
|
|
|
|
2004-08-30 08:13:26 +08:00
|
|
|
/// X86AddressMode - This struct holds a generalized full x86 address mode.
|
|
|
|
/// The base register can be a frame index, which will eventually be replaced
|
2004-10-15 12:43:20 +08:00
|
|
|
/// with BP or SP and Disp being offsetted accordingly. The displacement may
|
|
|
|
/// also include the offset of a global value.
|
2004-08-30 08:13:26 +08:00
|
|
|
struct X86AddressMode {
|
2005-01-18 07:25:45 +08:00
|
|
|
enum {
|
|
|
|
RegBase,
|
2006-05-25 01:04:05 +08:00
|
|
|
FrameIndexBase
|
2005-01-18 07:25:45 +08:00
|
|
|
} BaseType;
|
2005-04-22 07:38:14 +08:00
|
|
|
|
2005-01-18 07:25:45 +08:00
|
|
|
union {
|
|
|
|
unsigned Reg;
|
|
|
|
int FrameIndex;
|
|
|
|
} Base;
|
2005-04-22 07:38:14 +08:00
|
|
|
|
2005-01-18 07:25:45 +08:00
|
|
|
unsigned Scale;
|
|
|
|
unsigned IndexReg;
|
2009-09-16 02:27:02 +08:00
|
|
|
int Disp;
|
2010-04-15 09:51:59 +08:00
|
|
|
const GlobalValue *GV;
|
2009-07-01 11:27:19 +08:00
|
|
|
unsigned GVOpFlags;
|
2005-04-22 07:38:14 +08:00
|
|
|
|
2009-07-01 11:27:19 +08:00
|
|
|
X86AddressMode()
|
2014-04-28 12:05:08 +08:00
|
|
|
: BaseType(RegBase), Scale(1), IndexReg(0), Disp(0), GV(nullptr),
|
|
|
|
GVOpFlags(0) {
|
2005-01-18 07:25:45 +08:00
|
|
|
Base.Reg = 0;
|
|
|
|
}
|
2012-06-23 06:07:19 +08:00
|
|
|
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
void getFullAddress(SmallVectorImpl<MachineOperand> &MO) {
|
|
|
|
assert(Scale == 1 || Scale == 2 || Scale == 4 || Scale == 8);
|
2012-06-23 06:07:19 +08:00
|
|
|
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
if (BaseType == X86AddressMode::RegBase)
|
2016-08-19 01:56:27 +08:00
|
|
|
MO.push_back(MachineOperand::CreateReg(Base.Reg, false, false, false,
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
false, false, false, 0, false));
|
|
|
|
else {
|
|
|
|
assert(BaseType == X86AddressMode::FrameIndexBase);
|
|
|
|
MO.push_back(MachineOperand::CreateFI(Base.FrameIndex));
|
|
|
|
}
|
2012-06-23 06:07:19 +08:00
|
|
|
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
MO.push_back(MachineOperand::CreateImm(Scale));
|
2016-08-19 01:56:27 +08:00
|
|
|
MO.push_back(MachineOperand::CreateReg(IndexReg, false, false, false, false,
|
|
|
|
false, false, 0, false));
|
2012-06-23 06:07:19 +08:00
|
|
|
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
if (GV)
|
|
|
|
MO.push_back(MachineOperand::CreateGA(GV, Disp, GVOpFlags));
|
|
|
|
else
|
|
|
|
MO.push_back(MachineOperand::CreateImm(Disp));
|
2012-06-23 06:07:19 +08:00
|
|
|
|
2016-08-19 01:56:27 +08:00
|
|
|
MO.push_back(MachineOperand::CreateReg(0, false, false, false, false, false,
|
|
|
|
false, 0, false));
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
}
|
2004-08-30 08:13:26 +08:00
|
|
|
};
|
|
|
|
|
2016-03-30 11:10:24 +08:00
|
|
|
/// Compute the addressing mode from an machine instruction starting with the
|
|
|
|
/// given operand.
|
2016-11-24 21:05:43 +08:00
|
|
|
static inline X86AddressMode getAddressFromInstr(const MachineInstr *MI,
|
2016-03-30 11:10:24 +08:00
|
|
|
unsigned Operand) {
|
|
|
|
X86AddressMode AM;
|
2016-11-24 21:05:43 +08:00
|
|
|
const MachineOperand &Op0 = MI->getOperand(Operand);
|
|
|
|
if (Op0.isReg()) {
|
2016-03-30 11:10:24 +08:00
|
|
|
AM.BaseType = X86AddressMode::RegBase;
|
2016-11-24 21:05:43 +08:00
|
|
|
AM.Base.Reg = Op0.getReg();
|
2016-03-30 11:10:24 +08:00
|
|
|
} else {
|
|
|
|
AM.BaseType = X86AddressMode::FrameIndexBase;
|
2016-11-24 21:05:43 +08:00
|
|
|
AM.Base.FrameIndex = Op0.getIndex();
|
2016-03-30 11:10:24 +08:00
|
|
|
}
|
2016-11-24 21:05:43 +08:00
|
|
|
|
|
|
|
const MachineOperand &Op1 = MI->getOperand(Operand + 1);
|
|
|
|
AM.Scale = Op1.getImm();
|
|
|
|
|
|
|
|
const MachineOperand &Op2 = MI->getOperand(Operand + 2);
|
|
|
|
AM.IndexReg = Op2.getReg();
|
|
|
|
|
|
|
|
const MachineOperand &Op3 = MI->getOperand(Operand + 3);
|
|
|
|
if (Op3.isGlobal())
|
|
|
|
AM.GV = Op3.getGlobal();
|
|
|
|
else
|
|
|
|
AM.Disp = Op3.getImm();
|
|
|
|
|
2016-03-30 11:10:24 +08:00
|
|
|
return AM;
|
|
|
|
}
|
|
|
|
|
2002-11-18 05:03:35 +08:00
|
|
|
/// addDirectMem - This function is used to add a direct memory reference to the
|
2002-12-29 04:26:58 +08:00
|
|
|
/// current instruction -- that is, a dereference of an address in a register,
|
|
|
|
/// with no scale, index or displacement. An example is: DWORD PTR [EAX].
|
|
|
|
///
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
|
|
|
addDirectMem(const MachineInstrBuilder &MIB, unsigned Reg) {
|
2010-07-09 07:46:44 +08:00
|
|
|
// Because memory references are always represented with five
|
|
|
|
// values, this adds: Reg, 1, NoReg, 0, NoReg to the instruction.
|
|
|
|
return MIB.addReg(Reg).addImm(1).addReg(0).addImm(0).addReg(0);
|
2002-11-18 05:03:35 +08:00
|
|
|
}
|
|
|
|
|
2016-11-24 21:23:35 +08:00
|
|
|
/// Replace the address used in the instruction with the direct memory
|
|
|
|
/// reference.
|
|
|
|
static inline void setDirectAddressInInstr(MachineInstr *MI, unsigned Operand,
|
|
|
|
unsigned Reg) {
|
2019-09-12 05:56:17 +08:00
|
|
|
// Direct memory address is in a form of: Reg/FI, 1 (Scale), NoReg, 0, NoReg.
|
|
|
|
MI->getOperand(Operand).ChangeToRegister(Reg, /*isDef=*/false);
|
2016-11-24 21:23:35 +08:00
|
|
|
MI->getOperand(Operand + 1).setImm(1);
|
|
|
|
MI->getOperand(Operand + 2).setReg(0);
|
2019-09-12 05:56:17 +08:00
|
|
|
MI->getOperand(Operand + 3).ChangeToImmediate(0);
|
2016-11-24 21:23:35 +08:00
|
|
|
MI->getOperand(Operand + 4).setReg(0);
|
|
|
|
}
|
2009-04-09 05:14:34 +08:00
|
|
|
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
|
|
|
addOffset(const MachineInstrBuilder &MIB, int Offset) {
|
2010-07-09 07:46:44 +08:00
|
|
|
return MIB.addImm(1).addReg(0).addImm(Offset).addReg(0);
|
2009-04-09 05:14:34 +08:00
|
|
|
}
|
2002-11-23 06:42:12 +08:00
|
|
|
|
2016-12-08 03:29:18 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
|
|
|
addOffset(const MachineInstrBuilder &MIB, const MachineOperand& Offset) {
|
2017-01-13 17:58:52 +08:00
|
|
|
return MIB.addImm(1).addReg(0).add(Offset).addReg(0);
|
2016-12-08 03:29:18 +08:00
|
|
|
}
|
|
|
|
|
2002-12-29 04:26:58 +08:00
|
|
|
/// addRegOffset - This function is used to add a memory reference of the form
|
|
|
|
/// [Reg + Offset], i.e., one with no scale or index, but with a
|
|
|
|
/// displacement. An example is: DWORD PTR [EAX + 4].
|
|
|
|
///
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
|
|
|
addRegOffset(const MachineInstrBuilder &MIB,
|
|
|
|
unsigned Reg, bool isKill, int Offset) {
|
2009-05-14 05:33:08 +08:00
|
|
|
return addOffset(MIB.addReg(Reg, getKillRegState(isKill)), Offset);
|
2009-04-09 05:14:34 +08:00
|
|
|
}
|
|
|
|
|
2005-01-02 10:38:18 +08:00
|
|
|
/// addRegReg - This function is used to add a memory reference of the form:
|
|
|
|
/// [Reg + Reg].
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &addRegReg(const MachineInstrBuilder &MIB,
|
2008-07-03 17:09:37 +08:00
|
|
|
unsigned Reg1, bool isKill1,
|
|
|
|
unsigned Reg2, bool isKill2) {
|
2009-05-14 05:33:08 +08:00
|
|
|
return MIB.addReg(Reg1, getKillRegState(isKill1)).addImm(1)
|
2010-07-09 07:46:44 +08:00
|
|
|
.addReg(Reg2, getKillRegState(isKill2)).addImm(0).addReg(0);
|
2005-01-02 10:38:18 +08:00
|
|
|
}
|
|
|
|
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
2010-07-09 07:46:44 +08:00
|
|
|
addFullAddress(const MachineInstrBuilder &MIB,
|
|
|
|
const X86AddressMode &AM) {
|
|
|
|
assert(AM.Scale == 1 || AM.Scale == 2 || AM.Scale == 4 || AM.Scale == 8);
|
2012-06-23 06:07:19 +08:00
|
|
|
|
2004-08-30 08:13:26 +08:00
|
|
|
if (AM.BaseType == X86AddressMode::RegBase)
|
|
|
|
MIB.addReg(AM.Base.Reg);
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
else {
|
|
|
|
assert(AM.BaseType == X86AddressMode::FrameIndexBase);
|
2004-08-30 08:13:26 +08:00
|
|
|
MIB.addFrameIndex(AM.Base.FrameIndex);
|
implement rdar://6653118 - fastisel should fold loads where possible.
Since mem2reg isn't run at -O0, we get a ton of reloads from the stack,
for example, before, this code:
int foo(int x, int y, int z) {
return x+y+z;
}
used to compile into:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
movl 4(%rsp), %esi
addl %edx, %esi
movl (%rsp), %edx
addl %esi, %edx
movl %edx, %eax
addq $12, %rsp
ret
Now we produce:
_foo: ## @foo
subq $12, %rsp
movl %edi, 8(%rsp)
movl %esi, 4(%rsp)
movl %edx, (%rsp)
movl 8(%rsp), %edx
addl 4(%rsp), %edx ## Folded load
addl (%rsp), %edx ## Folded load
movl %edx, %eax
addq $12, %rsp
ret
Fewer instructions and less register use = faster compiles.
llvm-svn: 113102
2010-09-05 10:18:34 +08:00
|
|
|
}
|
|
|
|
|
2006-05-05 02:16:01 +08:00
|
|
|
MIB.addImm(AM.Scale).addReg(AM.IndexReg);
|
2004-10-15 12:43:20 +08:00
|
|
|
if (AM.GV)
|
2010-07-09 07:46:44 +08:00
|
|
|
MIB.addGlobalAddress(AM.GV, AM.Disp, AM.GVOpFlags);
|
2004-10-15 12:43:20 +08:00
|
|
|
else
|
2010-07-09 07:46:44 +08:00
|
|
|
MIB.addImm(AM.Disp);
|
2012-06-23 06:07:19 +08:00
|
|
|
|
2010-07-09 07:46:44 +08:00
|
|
|
return MIB.addReg(0);
|
2009-04-09 05:14:34 +08:00
|
|
|
}
|
|
|
|
|
2002-12-29 04:26:58 +08:00
|
|
|
/// addFrameReference - This function is used to add a reference to the base of
|
|
|
|
/// an abstract object on the stack frame of the current function. This
|
2003-01-13 08:45:53 +08:00
|
|
|
/// reference has base register as the FrameIndex offset until it is resolved.
|
|
|
|
/// This allows a constant offset to be specified as well...
|
2002-12-29 04:26:58 +08:00
|
|
|
///
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
2003-01-13 08:45:53 +08:00
|
|
|
addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0) {
|
2008-12-04 02:11:40 +08:00
|
|
|
MachineInstr *MI = MIB;
|
|
|
|
MachineFunction &MF = *MI->getParent()->getParent();
|
2016-07-29 02:40:00 +08:00
|
|
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
2011-06-29 03:10:37 +08:00
|
|
|
const MCInstrDesc &MCID = MI->getDesc();
|
2016-07-16 02:26:59 +08:00
|
|
|
auto Flags = MachineMemOperand::MONone;
|
2011-06-29 03:10:37 +08:00
|
|
|
if (MCID.mayLoad())
|
2008-12-04 02:11:40 +08:00
|
|
|
Flags |= MachineMemOperand::MOLoad;
|
2011-06-29 03:10:37 +08:00
|
|
|
if (MCID.mayStore())
|
2008-12-04 02:11:40 +08:00
|
|
|
Flags |= MachineMemOperand::MOStore;
|
2015-08-12 07:09:45 +08:00
|
|
|
MachineMemOperand *MMO = MF.getMachineMemOperand(
|
|
|
|
MachinePointerInfo::getFixedStack(MF, FI, Offset), Flags,
|
[Alignment][NFC] Use Align version of getMachineMemOperand
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: jyknight, sdardis, nemanjai, hiraditya, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, jfb, PkmX, jocewei, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77059
2020-03-30 22:45:57 +08:00
|
|
|
MFI.getObjectSize(FI), MFI.getObjectAlign(FI));
|
2009-04-09 05:14:34 +08:00
|
|
|
return addOffset(MIB.addFrameIndex(FI), Offset)
|
2008-12-04 02:11:40 +08:00
|
|
|
.addMemOperand(MMO);
|
2003-01-13 08:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// addConstantPoolReference - This function is used to add a reference to the
|
|
|
|
/// base of a constant value spilled to the per-function constant pool. The
|
2008-09-30 09:21:32 +08:00
|
|
|
/// reference uses the abstract ConstantPoolIndex which is retained until
|
|
|
|
/// either machine code emission or assembly output. In PIC mode on x86-32,
|
|
|
|
/// the GlobalBaseReg parameter can be used to make this a
|
|
|
|
/// GlobalBaseReg-relative reference.
|
2003-01-13 08:45:53 +08:00
|
|
|
///
|
2009-07-16 22:03:08 +08:00
|
|
|
static inline const MachineInstrBuilder &
|
2008-09-30 09:21:32 +08:00
|
|
|
addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
|
2009-06-27 09:31:51 +08:00
|
|
|
unsigned GlobalBaseReg, unsigned char OpFlags) {
|
2009-04-09 05:14:34 +08:00
|
|
|
//FIXME: factor this
|
|
|
|
return MIB.addReg(GlobalBaseReg).addImm(1).addReg(0)
|
2009-06-27 09:31:51 +08:00
|
|
|
.addConstantPoolIndex(CPI, 0, OpFlags).addReg(0);
|
2002-12-29 04:26:58 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 01:56:27 +08:00
|
|
|
} // end namespace llvm
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2016-08-19 01:56:27 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_X86_X86INSTRBUILDER_H
|