Skip to content

Commit

Permalink
[ARM][CodeGen] Add support for complex deinterleaving
Browse files Browse the repository at this point in the history
Adds the Complex Deinterleaving Pass implementing support for complex numbers in a target-independent manner, deferring to the TargetLowering for the given target to create a target-specific intrinsic.

Differential Revision: https://reviews.llvm.org/D114174
  • Loading branch information
NickGuy-Arm committed Nov 14, 2022
1 parent c92ff2a commit d52e283
Show file tree
Hide file tree
Showing 18 changed files with 2,495 additions and 1 deletion.
53 changes: 53 additions & 0 deletions llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
@@ -0,0 +1,53 @@
//===- ComplexDeinterleavingPass.h - Complex Deinterleaving Pass *- C++ -*-===//
//
// 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 pass implements generation of target-specific intrinsics to support
// handling of complex number arithmetic and deinterleaving.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_COMPLEXDEINTERLEAVING_H
#define LLVM_CODEGEN_COMPLEXDEINTERLEAVING_H

#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"

namespace llvm {

class Function;
class TargetMachine;

struct ComplexDeinterleavingPass
: public PassInfoMixin<ComplexDeinterleavingPass> {
private:
TargetMachine *TM;

public:
ComplexDeinterleavingPass(TargetMachine *TM) : TM(TM) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};

enum class ComplexDeinterleavingOperation {
CAdd,
CMulPartial,
// The following 'operations' are used to represent internal states. Backends
// are not expected to try and support these in any capacity.
Shuffle
};

enum class ComplexDeinterleavingRotation {
Rotation_0 = 0,
Rotation_90 = 1,
Rotation_180 = 2,
Rotation_270 = 3,
};

} // namespace llvm

#endif // LLVM_CODEGEN_COMPLEXDEINTERLEAVING_H
4 changes: 4 additions & 0 deletions llvm/include/llvm/CodeGen/Passes.h
Expand Up @@ -79,6 +79,10 @@ namespace llvm {
/// matching during instruction selection.
FunctionPass *createCodeGenPreparePass();

/// This pass implements generation of target-specific intrinsics to support
/// handling of complex number arithmetic
FunctionPass *createComplexDeinterleavingPass(const TargetMachine *TM);

/// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg
/// load-linked/store-conditional loops.
extern char &AtomicExpandID;
Expand Down
21 changes: 21 additions & 0 deletions llvm/include/llvm/CodeGen/TargetLowering.h
Expand Up @@ -27,6 +27,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/ComplexDeinterleavingPass.h"
#include "llvm/CodeGen/DAGCombine.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/LowLevelType.h"
Expand Down Expand Up @@ -3103,6 +3104,26 @@ class TargetLoweringBase {
return isOperationLegalOrCustom(Op, VT);
}

/// Does this target support complex deinterleaving
virtual bool isComplexDeinterleavingSupported() const { return false; }

/// Does this target support complex deinterleaving with the given operation
/// and type
virtual bool isComplexDeinterleavingOperationSupported(
ComplexDeinterleavingOperation Operation, Type *Ty) const {
return false;
}

/// Create the IR node for the given complex deinterleaving operation.
/// If one cannot be created using all the given inputs, nullptr should be
/// returned.
virtual Value *createComplexDeinterleavingIR(
Instruction *I, ComplexDeinterleavingOperation OperationType,
ComplexDeinterleavingRotation Rotation, Value *InputA, Value *InputB,
Value *Accumulator = nullptr) const {
return nullptr;
}

//===--------------------------------------------------------------------===//
// Runtime Library hooks
//
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/InitializePasses.h
Expand Up @@ -102,6 +102,7 @@ void initializeCallSiteSplittingLegacyPassPass(PassRegistry&);
void initializeCalledValuePropagationLegacyPassPass(PassRegistry &);
void initializeCheckDebugMachineModulePass(PassRegistry &);
void initializeCodeGenPreparePass(PassRegistry&);
void initializeComplexDeinterleavingLegacyPassPass(PassRegistry&);
void initializeConstantHoistingLegacyPassPass(PassRegistry&);
void initializeConstantMergeLegacyPassPass(PassRegistry&);
void initializeConstraintEliminationPass(PassRegistry &);
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/CMakeLists.txt
Expand Up @@ -43,6 +43,7 @@ add_llvm_component_library(LLVMCodeGen
CodeGenPassBuilder.cpp
CodeGenPrepare.cpp
CommandFlags.cpp
ComplexDeinterleavingPass.cpp
CriticalAntiDepBreaker.cpp
DeadMachineInstructionElim.cpp
DetectDeadLanes.cpp
Expand Down

0 comments on commit d52e283

Please sign in to comment.