LLVM 24.0.0git
ExecutionDomainFix.h
Go to the documentation of this file.
1//==-- llvm/CodeGen/ExecutionDomainFix.h - Execution Domain Fix -*- C++ -*--==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file Execution Domain Fix pass.
10///
11/// Some X86 SSE instructions like mov, and, or, xor are available in different
12/// variants for different operand types. These variant instructions are
13/// equivalent, but on Nehalem and newer cpus there is extra latency
14/// transferring data between integer and floating point domains. ARM cores
15/// have similar issues when they are configured with both VFP and NEON
16/// pipelines.
17///
18/// This pass changes the variant instructions to minimize domain crossings.
19//
20//===----------------------------------------------------------------------===//
21
22#ifndef LLVM_CODEGEN_EXECUTIONDOMAINFIX_H
23#define LLVM_CODEGEN_EXECUTIONDOMAINFIX_H
24
31#include "llvm/IR/Analysis.h"
32#include "llvm/IR/PassManager.h"
33
34namespace llvm {
35
36class MachineInstr;
37class TargetInstrInfo;
38
39/// A DomainValue is a bit like LiveIntervals' ValNo, but it also keeps track
40/// of execution domains.
41///
42/// An open DomainValue represents a set of instructions that can still switch
43/// execution domain. Multiple registers may refer to the same open
44/// DomainValue - they will eventually be collapsed to the same execution
45/// domain.
46///
47/// A collapsed DomainValue represents a single register that has been forced
48/// into one of more execution domains. There is a separate collapsed
49/// DomainValue for each register, but it may contain multiple execution
50/// domains. A register value is initially created in a single execution
51/// domain, but if we were forced to pay the penalty of a domain crossing, we
52/// keep track of the fact that the register is now available in multiple
53/// domains.
55 /// Basic reference counting.
56 unsigned Refs = 0;
57
58 /// Bitmask of available domains. For an open DomainValue, it is the still
59 /// possible domains for collapsing. For a collapsed DomainValue it is the
60 /// domains where the register is available for free.
62
63 /// Pointer to the next DomainValue in a chain. When two DomainValues are
64 /// merged, Victim.Next is set to point to Victor, so old DomainValue
65 /// references can be updated by following the chain.
67
68 /// Twiddleable instructions using or defining these registers.
70
72
73 /// A collapsed DomainValue has no instructions to twiddle - it simply keeps
74 /// track of the domains where the registers are already available.
75 bool isCollapsed() const { return Instrs.empty(); }
76
77 /// Is domain available?
78 bool hasDomain(unsigned domain) const {
79 assert(domain <
80 static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
81 "undefined behavior");
82 return AvailableDomains & (1u << domain);
83 }
84
85 /// Mark domain as available.
86 void addDomain(unsigned domain) {
87 assert(domain <
88 static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
89 "undefined behavior");
90 AvailableDomains |= 1u << domain;
91 }
92
93 // Restrict to a single domain available.
94 void setSingleDomain(unsigned domain) {
95 assert(domain <
96 static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
97 "undefined behavior");
98 AvailableDomains = 1u << domain;
99 }
100
101 /// Return bitmask of domains that are available and in mask.
102 unsigned getCommonDomains(unsigned mask) const {
103 return AvailableDomains & mask;
104 }
105
106 /// First domain available.
107 unsigned getFirstDomain() const {
109 }
110
111 /// Clear this DomainValue and point to next which has all its data.
112 void clear() {
114 Next = nullptr;
115 Instrs.clear();
116 }
117};
118
120public:
121 static char ID; // Pass identification, replacement for typeid
122
124
130
131 bool runOnMachineFunction(MachineFunction &MF) override;
132
134 return MachineFunctionProperties().setNoVRegs();
135 }
136
137 StringRef getPassName() const override { return "Execution Domain Fix"; }
138};
139
141 : public OptionalPassInfoMixin<ExecutionDomainFixPass> {
142public:
148};
149
150} // namespace llvm
151
152#endif // LLVM_CODEGEN_EXECUTIONDOMAINFIX_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static constexpr unsigned long long mask(BlockVerifier::State S)
#define LLVM_ABI
Definition Compiler.h:211
This header defines various interfaces for pass management in LLVM.
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
MachineFunctionProperties getRequiredProperties() const override
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
MachineFunctionProperties getRequiredProperties() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
Representation of each machine instruction.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetInstrInfo - Interface to description of machine instruction set.
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
Definition bit.h:204
unsigned getCommonDomains(unsigned mask) const
Return bitmask of domains that are available and in mask.
void clear()
Clear this DomainValue and point to next which has all its data.
SmallVector< MachineInstr *, 8 > Instrs
Twiddleable instructions using or defining these registers.
void setSingleDomain(unsigned domain)
bool isCollapsed() const
A collapsed DomainValue has no instructions to twiddle - it simply keeps track of the domains where t...
DomainValue * Next
Pointer to the next DomainValue in a chain.
void addDomain(unsigned domain)
Mark domain as available.
unsigned AvailableDomains
Bitmask of available domains.
unsigned Refs
Basic reference counting.
unsigned getFirstDomain() const
First domain available.
bool hasDomain(unsigned domain) const
Is domain available?
A CRTP mix-in for passes that can be skipped.