2010-04-21 03:22:34 +02:00
|
|
|
//===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- C++ -*-===//
|
|
|
|
//
|
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
|
2010-04-21 03:22:34 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2014-06-10 22:07:29 +02:00
|
|
|
// This file declares several CodeGen-specific LLVM IR analysis utilities.
|
2010-04-21 03:22:34 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_ANALYSIS_H
|
|
|
|
#define LLVM_CODEGEN_ANALYSIS_H
|
|
|
|
|
2011-07-13 12:26:04 +02:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2015-10-04 04:22:52 +02:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2010-04-21 03:22:34 +02:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2016-05-26 14:42:55 +02:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2010-04-21 03:22:34 +02:00
|
|
|
#include "llvm/CodeGen/ISDOpcodes.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/InlineAsm.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
2016-05-26 14:42:55 +02:00
|
|
|
#include "llvm/Support/CodeGen.h"
|
2010-04-21 03:22:34 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
2014-11-14 01:35:50 +01:00
|
|
|
class GlobalValue;
|
2019-04-10 19:27:56 +02:00
|
|
|
class LLT;
|
2015-10-04 04:22:52 +02:00
|
|
|
class MachineBasicBlock;
|
|
|
|
class MachineFunction;
|
2013-08-20 10:36:50 +02:00
|
|
|
class TargetLoweringBase;
|
2014-07-11 22:50:47 +02:00
|
|
|
class TargetLowering;
|
|
|
|
class TargetMachine;
|
2014-03-12 09:00:24 +01:00
|
|
|
struct EVT;
|
2010-04-21 03:22:34 +02:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Compute the linearized index of a member in a nested
|
2015-01-14 06:33:01 +01:00
|
|
|
/// aggregate/struct/array.
|
2010-04-21 03:22:34 +02:00
|
|
|
///
|
2015-01-14 06:33:01 +01:00
|
|
|
/// Given an LLVM IR aggregate type and a sequence of insertvalue or
|
|
|
|
/// extractvalue indices that identify a member, return the linearized index of
|
|
|
|
/// the start of the member, i.e the number of element in memory before the
|
2015-08-08 20:27:36 +02:00
|
|
|
/// sought one. This is disconnected from the number of bytes.
|
2015-01-14 06:33:01 +01:00
|
|
|
///
|
|
|
|
/// \param Ty is the type indexed by \p Indices.
|
|
|
|
/// \param Indices is an optional pointer in the indices list to the current
|
|
|
|
/// index.
|
|
|
|
/// \param IndicesEnd is the end of the indices list.
|
|
|
|
/// \param CurIndex is the current index in the recursion.
|
|
|
|
///
|
|
|
|
/// \returns \p CurIndex plus the linear index in \p Ty the indices list.
|
2011-07-18 06:54:35 +02:00
|
|
|
unsigned ComputeLinearIndex(Type *Ty,
|
2010-04-21 03:22:34 +02:00
|
|
|
const unsigned *Indices,
|
|
|
|
const unsigned *IndicesEnd,
|
|
|
|
unsigned CurIndex = 0);
|
|
|
|
|
2011-07-18 06:54:35 +02:00
|
|
|
inline unsigned ComputeLinearIndex(Type *Ty,
|
2011-07-13 12:26:04 +02:00
|
|
|
ArrayRef<unsigned> Indices,
|
|
|
|
unsigned CurIndex = 0) {
|
|
|
|
return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex);
|
|
|
|
}
|
|
|
|
|
2010-04-21 03:22:34 +02:00
|
|
|
/// ComputeValueVTs - Given an LLVM IR type, compute a sequence of
|
|
|
|
/// EVTs that represent all the individual underlying
|
|
|
|
/// non-aggregate types that comprise it.
|
|
|
|
///
|
|
|
|
/// If Offsets is non-null, it points to a vector to be filled in
|
|
|
|
/// with the in-memory offsets of each of the individual values.
|
|
|
|
///
|
2015-07-09 03:57:34 +02:00
|
|
|
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty,
|
2010-04-21 03:22:34 +02:00
|
|
|
SmallVectorImpl<EVT> &ValueVTs,
|
2014-04-14 02:51:57 +02:00
|
|
|
SmallVectorImpl<uint64_t> *Offsets = nullptr,
|
2010-04-21 03:22:34 +02:00
|
|
|
uint64_t StartingOffset = 0);
|
|
|
|
|
2019-05-01 14:37:30 +02:00
|
|
|
/// Variant of ComputeValueVTs that also produces the memory VTs.
|
|
|
|
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty,
|
|
|
|
SmallVectorImpl<EVT> &ValueVTs,
|
|
|
|
SmallVectorImpl<EVT> *MemVTs,
|
|
|
|
SmallVectorImpl<uint64_t> *Offsets = nullptr,
|
|
|
|
uint64_t StartingOffset = 0);
|
|
|
|
|
2019-04-10 19:27:56 +02:00
|
|
|
/// computeValueLLTs - Given an LLVM IR type, compute a sequence of
|
|
|
|
/// LLTs that represent all the individual underlying
|
|
|
|
/// non-aggregate types that comprise it.
|
|
|
|
///
|
|
|
|
/// If Offsets is non-null, it points to a vector to be filled in
|
|
|
|
/// with the in-memory offsets of each of the individual values.
|
|
|
|
///
|
|
|
|
void computeValueLLTs(const DataLayout &DL, Type &Ty,
|
|
|
|
SmallVectorImpl<LLT> &ValueTys,
|
|
|
|
SmallVectorImpl<uint64_t> *Offsets = nullptr,
|
|
|
|
uint64_t StartingOffset = 0);
|
|
|
|
|
2010-04-21 03:22:34 +02:00
|
|
|
/// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
|
2014-11-14 01:35:50 +01:00
|
|
|
GlobalValue *ExtractTypeInfo(Value *V);
|
2010-04-21 03:22:34 +02:00
|
|
|
|
|
|
|
/// hasInlineAsmMemConstraint - Return true if the inline asm instruction being
|
|
|
|
/// processed uses a memory 'm' constraint.
|
2010-10-29 19:29:13 +02:00
|
|
|
bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos,
|
2010-04-21 03:22:34 +02:00
|
|
|
const TargetLowering &TLI);
|
|
|
|
|
|
|
|
/// getFCmpCondCode - Return the ISD condition code corresponding to
|
|
|
|
/// the given LLVM IR floating-point condition code. This includes
|
|
|
|
/// consideration of global floating-point math flags.
|
|
|
|
///
|
|
|
|
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred);
|
|
|
|
|
2011-12-02 23:16:29 +01:00
|
|
|
/// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats,
|
|
|
|
/// return the equivalent code if we're allowed to assume that NaNs won't occur.
|
|
|
|
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC);
|
|
|
|
|
2010-04-21 03:22:34 +02:00
|
|
|
/// getICmpCondCode - Return the ISD condition code corresponding to
|
|
|
|
/// the given LLVM IR integer condition code.
|
|
|
|
///
|
|
|
|
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
|
|
|
|
|
|
|
|
/// Test if the given instruction is in a position to be optimized
|
|
|
|
/// with a tail-call. This roughly means that it's in a block with
|
|
|
|
/// a return and there's nothing that needs to be scheduled
|
|
|
|
/// between it and the return.
|
|
|
|
///
|
|
|
|
/// This function only tests target-independent requirements.
|
2020-04-14 08:04:52 +02:00
|
|
|
bool isInTailCallPosition(const CallBase &Call, const TargetMachine &TM);
|
2010-04-21 03:22:34 +02:00
|
|
|
|
2016-09-08 02:48:37 +02:00
|
|
|
/// Test if given that the input instruction is in the tail call position, if
|
|
|
|
/// there is an attribute mismatch between the caller and the callee that will
|
|
|
|
/// inhibit tail call optimizations.
|
|
|
|
/// \p AllowDifferingSizes is an output parameter which, if forming a tail call
|
|
|
|
/// is permitted, determines whether it's permitted only if the size of the
|
|
|
|
/// caller's and callee's return types match exactly.
|
|
|
|
bool attributesPermitTailCall(const Function *F, const Instruction *I,
|
|
|
|
const ReturnInst *Ret,
|
|
|
|
const TargetLoweringBase &TLI,
|
|
|
|
bool *AllowDifferingSizes = nullptr);
|
|
|
|
|
2013-08-20 10:36:50 +02:00
|
|
|
/// Test if given that the input instruction is in the tail call position if the
|
|
|
|
/// return type or any attributes of the function will inhibit tail call
|
|
|
|
/// optimization.
|
2016-09-08 02:48:37 +02:00
|
|
|
bool returnTypeIsEligibleForTailCall(const Function *F, const Instruction *I,
|
2013-08-20 10:36:50 +02:00
|
|
|
const ReturnInst *Ret,
|
|
|
|
const TargetLoweringBase &TLI);
|
|
|
|
|
2015-10-04 04:22:52 +02:00
|
|
|
DenseMap<const MachineBasicBlock *, int>
|
[WebAssembly] Add functions for EHScopes
Summary:
There are functions using the term 'funclet' to refer to both
1. an EH scopes, the structure of BBs that starts with
catchpad/cleanuppad and ends with catchret/cleanupret, and
2. a small function that gets outlined in AsmPrinter, which is the
original meaning of 'funclet'.
So far the two have been the same thing; EH scopes are always outlined
in AsmPrinter as funclets at the end of the compilation pipeline. But
now wasm also uses scope-based EH but does not outline those, so we now
need to correctly distinguish those two use cases in functions.
This patch splits `MachineBasicBlock::isFuncletEntry` into
`isFuncletEntry` and `isEHScopeEntry`, and
`MachineFunction::hasFunclets` into `hasFunclets` and `hasEHScopes`, in
order to distinguish the two different use cases. And this also changes
some uses of the term 'funclet' to 'scope' in `getFuncletMembership` and
change the function name to `getEHScopeMembership` because this function
is not about outlined funclets but about EH scope memberships.
This change is in the same vein as D45559.
Reviewers: majnemer, dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D47005
llvm-svn: 333045
2018-05-23 02:32:46 +02:00
|
|
|
getEHScopeMembership(const MachineFunction &MF);
|
2015-10-04 04:22:52 +02:00
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2010-04-21 03:22:34 +02:00
|
|
|
|
|
|
|
#endif
|