[llvm-branch-commits] [libcxx] [llvm] [libc] [flang] [libcxxabi] [lld] [compiler-rt] [clang-tools-extra] [clang] [lldb] [llvm-exegesis] Add support for validation counters (PR #76653)

2024-01-16 Thread Clement Courbet via llvm-branch-commits

https://github.com/legrosbuffle approved this pull request.


https://github.com/llvm/llvm-project/pull/76653
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] [compiler-rt] [clang] [llvm] [flang] [Flang][OpenMP] Restructure recursive lowering in `createBodyOfOp` (PR #77761)

2024-01-16 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/77761

>From 1b5524ae8874e389d373a55417919afa56beb2b5 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Mon, 8 Jan 2024 15:53:07 -0600
Subject: [PATCH 1/4] [Flang][OpenMP] Restructure recursive lowering in
 `createBodyOfOp`

This brings `createBodyOfOp` to its final intended form. First, input
privatization is performed, then the recursive lowering takes place,
and finally the output privatization (lastprivate) is done.

This enables fixing a known issue with infinite loops inside of an
OpenMP region, and the fix is included in this patch.

Fixes https://github.com/llvm/llvm-project/issues/74348.

Recursive lowering [5/5]
---
 flang/include/flang/Lower/OpenMP.h|   4 +-
 flang/lib/Lower/OpenMP.cpp| 133 --
 flang/test/Lower/OpenMP/FIR/sections.f90  |   6 +-
 .../OpenMP/infinite-loop-in-construct.f90 |  19 +++
 flang/test/Lower/OpenMP/sections.f90  |   6 +-
 5 files changed, 119 insertions(+), 49 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/infinite-loop-in-construct.f90

diff --git a/flang/include/flang/Lower/OpenMP.h 
b/flang/include/flang/Lower/OpenMP.h
index 6e772c43d8c46e..477d3e7d9da3a8 100644
--- a/flang/include/flang/Lower/OpenMP.h
+++ b/flang/include/flang/Lower/OpenMP.h
@@ -50,8 +50,8 @@ struct Variable;
 } // namespace pft
 
 // Generate the OpenMP terminator for Operation at Location.
-void genOpenMPTerminator(fir::FirOpBuilder &, mlir::Operation *,
- mlir::Location);
+mlir::Operation *genOpenMPTerminator(fir::FirOpBuilder &, mlir::Operation *,
+ mlir::Location);
 
 void genOpenMPConstruct(AbstractConverter &, Fortran::lower::SymMap &,
 semantics::SemanticsContext &, pft::Evaluation &,
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 6e93387fbff7cc..bb92fdce4ac56e 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -383,7 +383,8 @@ void 
DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
 // construct
 mlir::OpBuilder::InsertPoint unstructuredSectionsIP =
 firOpBuilder.saveInsertionPoint();
-firOpBuilder.setInsertionPointToStart(&op->getRegion(0).back());
+mlir::Operation *lastOper = 
op->getRegion(0).back().getTerminator();
+firOpBuilder.setInsertionPoint(lastOper);
 lastPrivIP = firOpBuilder.saveInsertionPoint();
 firOpBuilder.restoreInsertionPoint(unstructuredSectionsIP);
   }
@@ -2133,15 +2134,6 @@ static mlir::Type 
getLoopVarType(Fortran::lower::AbstractConverter &converter,
   return converter.getFirOpBuilder().getIntegerType(loopVarTypeSize);
 }
 
-static void resetBeforeTerminator(fir::FirOpBuilder &firOpBuilder,
-  mlir::Operation *storeOp,
-  mlir::Block &block) {
-  if (storeOp)
-firOpBuilder.setInsertionPointAfter(storeOp);
-  else
-firOpBuilder.setInsertionPointToStart(&block);
-}
-
 static mlir::Operation *
 createAndSetPrivatizedLoopVar(Fortran::lower::AbstractConverter &converter,
   mlir::Location loc, mlir::Value indexVal,
@@ -2183,11 +2175,43 @@ static void createBodyOfOp(
 const llvm::SmallVector &args = {},
 bool outerCombined = false, DataSharingProcessor *dsp = nullptr) {
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
+
+  auto insertMarker = [](fir::FirOpBuilder &builder) {
+mlir::Value undef = builder.create(builder.getUnknownLoc(),
+ builder.getIndexType());
+return undef.getDefiningOp();
+  };
+
+  // Find the block where the OMP terminator should go. In simple cases
+  // it is the single block in the operation's region. When the region
+  // is more complicated, especially with unstructured control flow, there
+  // may be multiple blocks, and some of them may have non-OMP terminators
+  // resulting from lowering of the code contained within the operation.
+  // By OpenMP rules, there should be a single exit point from the region:
+  // here exit means transfering control to the code following the operation.
+  // STOP statement is allowed and does not count as exit for the purpose of
+  // inserting terminators.
+  auto findExitBlock = [&](mlir::Region ®ion) -> mlir::Block * {
+auto isTerminated = [](mlir::Block &block) -> bool {
+  if (block.empty())
+return false;
+  return block.back().hasTrait();
+};
+
+mlir::Block *exit = nullptr;
+for (auto &block : region) {
+  if (!isTerminated(block)) {
+assert(exit == nullptr && "Multiple exit block in OpenMP region");
+exit = █
+  }
+}
+return exit;
+  };
+
   // If an argument for the region is provided then create the block with that
   // argument. Also up

[llvm-branch-commits] [clang] [llvm] [SPARC] Prefer RDPC over CALL to implement GETPCX for 64-bit target (PR #77196)

2024-01-16 Thread via llvm-branch-commits

koachan wrote:

Okay, new PR is at https://github.com/llvm/llvm-project/pull/78280.

https://github.com/llvm/llvm-project/pull/77196
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (PR #78289)

2024-01-16 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak created 
https://github.com/llvm/llvm-project/pull/78289

This patch forwards the target CPU and features information from the Flang 
frontend to MLIR func.func operation attributes, which are later used to 
populate the target_cpu and target_features llvm.func attributes.

This completes a full flow by which target CPU and features make it all the way 
from compiler options to LLVM IR function attributes.

>From a1701f9108840bd7ac889a91e868df0f1334a84c Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 16 Jan 2024 13:38:49 +
Subject: [PATCH] [Flang][Lower] Attach target_cpu and target_features
 attributes to MLIR functions

This patch forwards the target CPU and features information from the Flang
frontend to MLIR func.func operation attributes, which are later used to
populate the target_cpu and target_features llvm.func attributes.

This completes a full flow by which target CPU and features make it all the way
from compiler options to LLVM IR function attributes.
---
 flang/include/flang/Lower/Bridge.h  | 14 ++---
 flang/lib/Frontend/FrontendActions.cpp  |  4 +---
 flang/lib/Lower/Bridge.cpp  | 21 +++
 flang/test/Driver/save-mlir-temps.f90   |  6 +++---
 flang/test/Lower/target-features-amdgcn.f90 | 23 +
 flang/test/Lower/target-features-x86_64.f90 | 21 +++
 flang/tools/bbc/bbc.cpp |  3 +--
 7 files changed, 73 insertions(+), 19 deletions(-)
 create mode 100644 flang/test/Lower/target-features-amdgcn.f90
 create mode 100644 flang/test/Lower/target-features-x86_64.f90

diff --git a/flang/include/flang/Lower/Bridge.h 
b/flang/include/flang/Lower/Bridge.h
index 6c0d14d65edae1e..4864a08d9977b8e 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -21,10 +21,7 @@
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
 #include "mlir/IR/BuiltinOps.h"
-
-namespace llvm {
-class DataLayout;
-} // namespace llvm
+#include "llvm/Target/TargetMachine.h"
 
 namespace Fortran {
 namespace common {
@@ -64,11 +61,11 @@ class LoweringBridge {
  const Fortran::lower::LoweringOptions &loweringOptions,
  const std::vector &envDefaults,
  const Fortran::common::LanguageFeatureControl &languageFeatures,
- const llvm::DataLayout *dataLayout = nullptr) {
+ const llvm::TargetMachine &targetMachine) {
 return LoweringBridge(ctx, semanticsContext, defaultKinds, intrinsics,
   targetCharacteristics, allCooked, triple, kindMap,
   loweringOptions, envDefaults, languageFeatures,
-  dataLayout);
+  targetMachine);
   }
 
   
//======//
@@ -110,6 +107,8 @@ class LoweringBridge {
 return languageFeatures;
   }
 
+  const llvm::TargetMachine &getTargetMachine() const { return targetMachine; }
+
   /// Create a folding context. Careful: this is very expensive.
   Fortran::evaluate::FoldingContext createFoldingContext() const;
 
@@ -147,7 +146,7 @@ class LoweringBridge {
   const Fortran::lower::LoweringOptions &loweringOptions,
   const std::vector &envDefaults,
   const Fortran::common::LanguageFeatureControl &languageFeatures,
-  const llvm::DataLayout *dataLayout);
+  const llvm::TargetMachine &targetMachine);
   LoweringBridge() = delete;
   LoweringBridge(const LoweringBridge &) = delete;
 
@@ -164,6 +163,7 @@ class LoweringBridge {
   const Fortran::lower::LoweringOptions &loweringOptions;
   const std::vector &envDefaults;
   const Fortran::common::LanguageFeatureControl &languageFeatures;
+  const llvm::TargetMachine &targetMachine;
 };
 
 } // namespace lower
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index 74e3992d5ab62ba..397e403847588e0 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -285,8 +285,6 @@ bool CodeGenAction::beginSourceFileAction() {
   ci.getSemanticsContext().defaultKinds();
   fir::KindMapping kindMap(mlirCtx.get(), llvm::ArrayRef{
   
fir::fromDefaultKinds(defKinds)});
-  const llvm::DataLayout &dl = targetMachine.createDataLayout();
-
   lower::LoweringBridge lb = Fortran::lower::LoweringBridge::create(
   *mlirCtx, ci.getSemanticsContext(), defKinds,
   ci.getSemanticsContext().intrinsics(),
@@ -294,7 +292,7 @@ bool CodeGenAction::beginSourceFileAction() {
   ci.getParsing().allCooked(), ci.getInvocation().getTargetOpts().triple,
   kindMap, ci.getInvocation().getLoweringOpts(),
   ci.getInvocation().getFrontendOpts().envDefaults,
-  ci.getInvocation().getFrontendOpts().features, &dl);
+  ci.getInvocation().getFrontendOpts().features, targetMachine);
 
   // Fetch mo

[llvm-branch-commits] [flang] [Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (PR #78289)

2024-01-16 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-flang-fir-hlfir

Author: Sergio Afonso (skatrak)


Changes

This patch forwards the target CPU and features information from the Flang 
frontend to MLIR func.func operation attributes, which are later used to 
populate the target_cpu and target_features llvm.func attributes.

This completes a full flow by which target CPU and features make it all the way 
from compiler options to LLVM IR function attributes.

---
Full diff: https://github.com/llvm/llvm-project/pull/78289.diff


7 Files Affected:

- (modified) flang/include/flang/Lower/Bridge.h (+7-7) 
- (modified) flang/lib/Frontend/FrontendActions.cpp (+1-3) 
- (modified) flang/lib/Lower/Bridge.cpp (+17-4) 
- (modified) flang/test/Driver/save-mlir-temps.f90 (+3-3) 
- (added) flang/test/Lower/target-features-amdgcn.f90 (+23) 
- (added) flang/test/Lower/target-features-x86_64.f90 (+21) 
- (modified) flang/tools/bbc/bbc.cpp (+1-2) 


``diff
diff --git a/flang/include/flang/Lower/Bridge.h 
b/flang/include/flang/Lower/Bridge.h
index 6c0d14d65edae1..4864a08d9977b8 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -21,10 +21,7 @@
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/Support/KindMapping.h"
 #include "mlir/IR/BuiltinOps.h"
-
-namespace llvm {
-class DataLayout;
-} // namespace llvm
+#include "llvm/Target/TargetMachine.h"
 
 namespace Fortran {
 namespace common {
@@ -64,11 +61,11 @@ class LoweringBridge {
  const Fortran::lower::LoweringOptions &loweringOptions,
  const std::vector &envDefaults,
  const Fortran::common::LanguageFeatureControl &languageFeatures,
- const llvm::DataLayout *dataLayout = nullptr) {
+ const llvm::TargetMachine &targetMachine) {
 return LoweringBridge(ctx, semanticsContext, defaultKinds, intrinsics,
   targetCharacteristics, allCooked, triple, kindMap,
   loweringOptions, envDefaults, languageFeatures,
-  dataLayout);
+  targetMachine);
   }
 
   
//======//
@@ -110,6 +107,8 @@ class LoweringBridge {
 return languageFeatures;
   }
 
+  const llvm::TargetMachine &getTargetMachine() const { return targetMachine; }
+
   /// Create a folding context. Careful: this is very expensive.
   Fortran::evaluate::FoldingContext createFoldingContext() const;
 
@@ -147,7 +146,7 @@ class LoweringBridge {
   const Fortran::lower::LoweringOptions &loweringOptions,
   const std::vector &envDefaults,
   const Fortran::common::LanguageFeatureControl &languageFeatures,
-  const llvm::DataLayout *dataLayout);
+  const llvm::TargetMachine &targetMachine);
   LoweringBridge() = delete;
   LoweringBridge(const LoweringBridge &) = delete;
 
@@ -164,6 +163,7 @@ class LoweringBridge {
   const Fortran::lower::LoweringOptions &loweringOptions;
   const std::vector &envDefaults;
   const Fortran::common::LanguageFeatureControl &languageFeatures;
+  const llvm::TargetMachine &targetMachine;
 };
 
 } // namespace lower
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index 74e3992d5ab62b..397e403847588e 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -285,8 +285,6 @@ bool CodeGenAction::beginSourceFileAction() {
   ci.getSemanticsContext().defaultKinds();
   fir::KindMapping kindMap(mlirCtx.get(), llvm::ArrayRef{
   
fir::fromDefaultKinds(defKinds)});
-  const llvm::DataLayout &dl = targetMachine.createDataLayout();
-
   lower::LoweringBridge lb = Fortran::lower::LoweringBridge::create(
   *mlirCtx, ci.getSemanticsContext(), defKinds,
   ci.getSemanticsContext().intrinsics(),
@@ -294,7 +292,7 @@ bool CodeGenAction::beginSourceFileAction() {
   ci.getParsing().allCooked(), ci.getInvocation().getTargetOpts().triple,
   kindMap, ci.getInvocation().getLoweringOpts(),
   ci.getInvocation().getFrontendOpts().envDefaults,
-  ci.getInvocation().getFrontendOpts().features, &dl);
+  ci.getInvocation().getFrontendOpts().features, targetMachine);
 
   // Fetch module from lb, so we can set
   mlirModule = std::make_unique(lb.getModule());
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 8006b9b426f4dc..27e6e46c52d825 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -54,6 +54,7 @@
 #include "flang/Semantics/symbol.h"
 #include "flang/Semantics/tools.h"
 #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
+#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
 #include "mlir/IR/PatternMatch.h"
 #include "mlir/Parser/Parser.h"
 #include "mlir/Transforms/RegionUtils.h"
@@ -4290,6 +4291,18 @@ class FirConverter : public 
Fortran::lower::AbstractConverter {
 assert(blockId

[llvm-branch-commits] [mlir] [flang] [Flang][MLIR][OpenMP] Use function-attached target attributes for OpenMP lowering (PR #78291)

2024-01-16 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak created 
https://github.com/llvm/llvm-project/pull/78291

This patch removes the omp.target module attribute, since the information it 
held on the target CPU and features is available to each function as a function 
attribute. Target outlining during the MLIR to LLVM IR translation stage is 
also updated, so that these attributes are passed along to the newly created 
function.

>From 52669d2fdd1f36f1a1a2e5b3845da09ec9c846b3 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 16 Jan 2024 14:11:48 +
Subject: [PATCH] [Flang][MLIR][OpenMP] Use function-attached target attributes
 for OpenMP lowering

This patch removes the omp.target module attribute, since the information it
held on the target CPU and features is available to each function as a function
attribute. Target outlining during the MLIR to LLVM IR translation stage is
also updated, so that these attributes are passed along to the newly created
function.
---
 flang/include/flang/Tools/CrossToolHelpers.h  | 11 
 flang/lib/Frontend/FrontendActions.cpp|  3 --
 .../Lower/OpenMP/FIR/target_cpu_features.f90  | 22 +--
 .../test/Lower/OpenMP/target_cpu_features.f90 | 22 +--
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  9 --
 .../Dialect/OpenMP/OpenMPOpsInterfaces.td | 28 ---
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  | 23 +--
 .../LLVMIR/omptarget-parallel-llvm.mlir   |  2 +-
 .../LLVMIR/omptarget-target-cpu-features.mlir | 23 +++
 9 files changed, 70 insertions(+), 73 deletions(-)
 create mode 100644 mlir/test/Target/LLVMIR/omptarget-target-cpu-features.mlir

diff --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index b61224ff4f1b3cd..5c59c99675699d2 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -109,17 +109,6 @@ void setOffloadModuleInterfaceAttributes(
   }
 }
 
-//  Shares assinging of the OpenMP OffloadModuleInterface and its TargetCPU
-//  attribute accross Flang tools (bbc/flang)
-void setOffloadModuleInterfaceTargetAttribute(mlir::ModuleOp &module,
-llvm::StringRef targetCPU, llvm::StringRef targetFeatures) {
-  // Should be registered by the OpenMPDialect
-  if (auto offloadMod = llvm::dyn_cast(
-  module.getOperation())) {
-offloadMod.setTarget(targetCPU, targetFeatures);
-  }
-}
-
 void setOpenMPVersionAttribute(mlir::ModuleOp &module, int64_t version) {
   module.getOperation()->setAttr(
   mlir::StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index 397e403847588e0..85dc1a0836421eb 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -301,9 +301,6 @@ bool CodeGenAction::beginSourceFileAction() {
   Fortran::common::LanguageFeature::OpenMP)) {
 setOffloadModuleInterfaceAttributes(*mlirModule,
 ci.getInvocation().getLangOpts());
-setOffloadModuleInterfaceTargetAttribute(
-*mlirModule, targetMachine.getTargetCPU(),
-targetMachine.getTargetFeatureString());
 setOpenMPVersionAttribute(*mlirModule,
   ci.getInvocation().getLangOpts().OpenMPVersion);
   }
diff --git a/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90 
b/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
index 179b71b3f0cfa5c..46051e03179e183 100644
--- a/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
+++ b/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
@@ -1,5 +1,5 @@
 !REQUIRES: amdgpu-registered-target, nvptx-registered-target
-!RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+!RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck --check-prefix=AMDGCN %s
 !RUN: %flang_fc1 -emit-hlfir -triple nvptx64-nvidia-cuda -target-cpu sm_80 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck --check-prefix=NVPTX %s
 
 
@@ -7,16 +7,20 @@
 ! Target_Enter Simple
 
!===
 
-!CHECK: omp.target = #omp.target
-!NVPTX: omp.target = #omp.target
-!CHECK-LABEL: func.func @_QPomp_target_simple()
+!AMDGCN-LABEL: func.func @_QPomp_target_simple() attributes {
+!AMDGCN-SAME: target_cpu = "gfx908"
+!AMDGCN-SAME: target_features = #llvm.target_features<["+16-bit-insts", 
"+ci-insts",
+!AMDGCN-SAME: "+dl-insts", "+dot1-insts", "+dot10-insts", "+dot2-insts", 
"+dot3-insts",
+!AMDGCN-SAME: "+dot4-insts", "+dot5-insts", "+dot6-insts", "+dot7-insts", 
"+dpp",
+!AMDGCN-SAME: "+gfx8-insts", "+gfx9-insts", "+gws", "+image-insts", 
"+mai-insts",
+!AMDGCN-SAME: "+s-memrealtime", "+s-memtime-inst", "+wavefrontsize64"]>
+
+!NVPTX-LABEL: func.func @_QPo

[llvm-branch-commits] [flang] [mlir] [Flang][MLIR][OpenMP] Use function-attached target attributes for OpenMP lowering (PR #78291)

2024-01-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-openmp

Author: Sergio Afonso (skatrak)


Changes

This patch removes the omp.target module attribute, since the information it 
held on the target CPU and features is available to each function as a function 
attribute. Target outlining during the MLIR to LLVM IR translation stage is 
also updated, so that these attributes are passed along to the newly created 
function.

---
Full diff: https://github.com/llvm/llvm-project/pull/78291.diff


9 Files Affected:

- (modified) flang/include/flang/Tools/CrossToolHelpers.h (-11) 
- (modified) flang/lib/Frontend/FrontendActions.cpp (-3) 
- (modified) flang/test/Lower/OpenMP/FIR/target_cpu_features.f90 (+13-9) 
- (modified) flang/test/Lower/OpenMP/target_cpu_features.f90 (+13-9) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (-9) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td (-28) 
- (modified) 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+20-3) 
- (modified) mlir/test/Target/LLVMIR/omptarget-parallel-llvm.mlir (+1-1) 
- (added) mlir/test/Target/LLVMIR/omptarget-target-cpu-features.mlir (+23) 


``diff
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index b61224ff4f1b3cd..5c59c99675699d2 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -109,17 +109,6 @@ void setOffloadModuleInterfaceAttributes(
   }
 }
 
-//  Shares assinging of the OpenMP OffloadModuleInterface and its TargetCPU
-//  attribute accross Flang tools (bbc/flang)
-void setOffloadModuleInterfaceTargetAttribute(mlir::ModuleOp &module,
-llvm::StringRef targetCPU, llvm::StringRef targetFeatures) {
-  // Should be registered by the OpenMPDialect
-  if (auto offloadMod = llvm::dyn_cast(
-  module.getOperation())) {
-offloadMod.setTarget(targetCPU, targetFeatures);
-  }
-}
-
 void setOpenMPVersionAttribute(mlir::ModuleOp &module, int64_t version) {
   module.getOperation()->setAttr(
   mlir::StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index 397e403847588e0..85dc1a0836421eb 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -301,9 +301,6 @@ bool CodeGenAction::beginSourceFileAction() {
   Fortran::common::LanguageFeature::OpenMP)) {
 setOffloadModuleInterfaceAttributes(*mlirModule,
 ci.getInvocation().getLangOpts());
-setOffloadModuleInterfaceTargetAttribute(
-*mlirModule, targetMachine.getTargetCPU(),
-targetMachine.getTargetFeatureString());
 setOpenMPVersionAttribute(*mlirModule,
   ci.getInvocation().getLangOpts().OpenMPVersion);
   }
diff --git a/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90 
b/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
index 179b71b3f0cfa5c..46051e03179e183 100644
--- a/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
+++ b/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
@@ -1,5 +1,5 @@
 !REQUIRES: amdgpu-registered-target, nvptx-registered-target
-!RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+!RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck --check-prefix=AMDGCN %s
 !RUN: %flang_fc1 -emit-hlfir -triple nvptx64-nvidia-cuda -target-cpu sm_80 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck --check-prefix=NVPTX %s
 
 
@@ -7,16 +7,20 @@
 ! Target_Enter Simple
 
!===
 
-!CHECK: omp.target = #omp.target
-!NVPTX: omp.target = #omp.target
-!CHECK-LABEL: func.func @_QPomp_target_simple()
+!AMDGCN-LABEL: func.func @_QPomp_target_simple() attributes {
+!AMDGCN-SAME: target_cpu = "gfx908"
+!AMDGCN-SAME: target_features = #llvm.target_features<["+16-bit-insts", 
"+ci-insts",
+!AMDGCN-SAME: "+dl-insts", "+dot1-insts", "+dot10-insts", "+dot2-insts", 
"+dot3-insts",
+!AMDGCN-SAME: "+dot4-insts", "+dot5-insts", "+dot6-insts", "+dot7-insts", 
"+dpp",
+!AMDGCN-SAME: "+gfx8-insts", "+gfx9-insts", "+gws", "+image-insts", 
"+mai-insts",
+!AMDGCN-SAME: "+s-memrealtime", "+s-memtime-inst", "+wavefrontsize64"]>
+
+!NVPTX-LABEL: func.func @_QPomp_target_simple() attributes {
+!NVPTX-SAME: target_cpu = "sm_80"
+!NVPTX-SAME: target_features = #llvm.target_features<["+ptx61", "+sm_80"]>
+
 subroutine omp_target_simple
   ! Directive needed to prevent subroutine from being filtered out when
   ! compiling for the device.
   !$omp declare target
 end subroutine omp_target_simple
-
diff --git a/flang/test/Lower/OpenMP/target_cpu_features.f90 
b/flang/test/Lower/OpenMP/target_cpu_features.f90
index ea1e5e38fca88ef..aa0b049565b99af 100644

[llvm-branch-commits] [flang] [mlir] [Flang][MLIR][OpenMP] Use function-attached target attributes for OpenMP lowering (PR #78291)

2024-01-16 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-flang-driver
@llvm/pr-subscribers-flang-fir-hlfir

@llvm/pr-subscribers-mlir

Author: Sergio Afonso (skatrak)


Changes

This patch removes the omp.target module attribute, since the information it 
held on the target CPU and features is available to each function as a function 
attribute. Target outlining during the MLIR to LLVM IR translation stage is 
also updated, so that these attributes are passed along to the newly created 
function.

---
Full diff: https://github.com/llvm/llvm-project/pull/78291.diff


9 Files Affected:

- (modified) flang/include/flang/Tools/CrossToolHelpers.h (-11) 
- (modified) flang/lib/Frontend/FrontendActions.cpp (-3) 
- (modified) flang/test/Lower/OpenMP/FIR/target_cpu_features.f90 (+13-9) 
- (modified) flang/test/Lower/OpenMP/target_cpu_features.f90 (+13-9) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (-9) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td (-28) 
- (modified) 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+20-3) 
- (modified) mlir/test/Target/LLVMIR/omptarget-parallel-llvm.mlir (+1-1) 
- (added) mlir/test/Target/LLVMIR/omptarget-target-cpu-features.mlir (+23) 


``diff
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index b61224ff4f1b3c..5c59c99675699d 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -109,17 +109,6 @@ void setOffloadModuleInterfaceAttributes(
   }
 }
 
-//  Shares assinging of the OpenMP OffloadModuleInterface and its TargetCPU
-//  attribute accross Flang tools (bbc/flang)
-void setOffloadModuleInterfaceTargetAttribute(mlir::ModuleOp &module,
-llvm::StringRef targetCPU, llvm::StringRef targetFeatures) {
-  // Should be registered by the OpenMPDialect
-  if (auto offloadMod = llvm::dyn_cast(
-  module.getOperation())) {
-offloadMod.setTarget(targetCPU, targetFeatures);
-  }
-}
-
 void setOpenMPVersionAttribute(mlir::ModuleOp &module, int64_t version) {
   module.getOperation()->setAttr(
   mlir::StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index 397e403847588e..85dc1a0836421e 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -301,9 +301,6 @@ bool CodeGenAction::beginSourceFileAction() {
   Fortran::common::LanguageFeature::OpenMP)) {
 setOffloadModuleInterfaceAttributes(*mlirModule,
 ci.getInvocation().getLangOpts());
-setOffloadModuleInterfaceTargetAttribute(
-*mlirModule, targetMachine.getTargetCPU(),
-targetMachine.getTargetFeatureString());
 setOpenMPVersionAttribute(*mlirModule,
   ci.getInvocation().getLangOpts().OpenMPVersion);
   }
diff --git a/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90 
b/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
index 179b71b3f0cfa5..46051e03179e18 100644
--- a/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
+++ b/flang/test/Lower/OpenMP/FIR/target_cpu_features.f90
@@ -1,5 +1,5 @@
 !REQUIRES: amdgpu-registered-target, nvptx-registered-target
-!RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+!RUN: %flang_fc1 -emit-fir -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck --check-prefix=AMDGCN %s
 !RUN: %flang_fc1 -emit-hlfir -triple nvptx64-nvidia-cuda -target-cpu sm_80 
-fopenmp -fopenmp-is-target-device %s -o - | FileCheck --check-prefix=NVPTX %s
 
 
@@ -7,16 +7,20 @@
 ! Target_Enter Simple
 
!===
 
-!CHECK: omp.target = #omp.target
-!NVPTX: omp.target = #omp.target
-!CHECK-LABEL: func.func @_QPomp_target_simple()
+!AMDGCN-LABEL: func.func @_QPomp_target_simple() attributes {
+!AMDGCN-SAME: target_cpu = "gfx908"
+!AMDGCN-SAME: target_features = #llvm.target_features<["+16-bit-insts", 
"+ci-insts",
+!AMDGCN-SAME: "+dl-insts", "+dot1-insts", "+dot10-insts", "+dot2-insts", 
"+dot3-insts",
+!AMDGCN-SAME: "+dot4-insts", "+dot5-insts", "+dot6-insts", "+dot7-insts", 
"+dpp",
+!AMDGCN-SAME: "+gfx8-insts", "+gfx9-insts", "+gws", "+image-insts", 
"+mai-insts",
+!AMDGCN-SAME: "+s-memrealtime", "+s-memtime-inst", "+wavefrontsize64"]>
+
+!NVPTX-LABEL: func.func @_QPomp_target_simple() attributes {
+!NVPTX-SAME: target_cpu = "sm_80"
+!NVPTX-SAME: target_features = #llvm.target_features<["+ptx61", "+sm_80"]>
+
 subroutine omp_target_simple
   ! Directive needed to prevent subroutine from being filtered out when
   ! compiling for the device.
   !$omp declare target
 end subroutine omp_target_simple
-
diff --git a/flang/test/Lower/OpenMP/target_cpu_features.f90 
b/flang/test/Lower/OpenMP/target_cpu_

[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)

2024-01-16 Thread Nikolas Klauser via llvm-branch-commits

https://github.com/philnik777 approved this pull request.

I'm OK with this as a quick fix, since Mark promised to fix it properly in the 
long term.

https://github.com/llvm/llvm-project/pull/76268
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (PR #78289)

2024-01-16 Thread Kiran Chandramohan via llvm-branch-commits


@@ -4290,6 +4291,18 @@ class FirConverter : public 
Fortran::lower::AbstractConverter {
 assert(blockId == 0 && "invalid blockId");
 assert(activeConstructStack.empty() && "invalid construct stack state");
 
+// Set target_cpu and target_features attributes to be passed through to 
the
+// llvm.func operation during lowering.
+const llvm::TargetMachine &targetMachine = bridge.getTargetMachine();
+if (auto targetCPU = targetMachine.getTargetCPU(); !targetCPU.empty())
+  func->setAttr("target_cpu",
+mlir::StringAttr::get(func.getContext(), targetCPU));
+
+if (auto targetFeatures = targetMachine.getTargetFeatureString();
+!targetFeatures.empty())
+  func->setAttr("target_features", mlir::LLVM::TargetFeaturesAttr::get(
+   func.getContext(), targetFeatures));

kiranchandramohan wrote:

The default question here would be whether we are going to use this information 
in HLFIR/FIR transformations and if not whether it is better to delay adding 
this information closer to conversion to LLVM dialect or potentially later.

If it is closer to conversion to LLVM dialect then you might be able to reuse 
the pass that added `frame-pointer` attribute. 
https://github.com/llvm/llvm-project/pull/74598

Please wait for opinion from others as well.

https://github.com/llvm/llvm-project/pull/78289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [mlir] [Flang][MLIR][OpenMP] Use function-attached target attributes for OpenMP lowering (PR #78291)

2024-01-16 Thread Kiran Chandramohan via llvm-branch-commits

https://github.com/kiranchandramohan approved this pull request.

LGTM. Please wait for @DominikAdamski 

Not for this patch, but would we need to add this info for all outlined 
functions?

https://github.com/llvm/llvm-project/pull/78291
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (PR #78289)

2024-01-16 Thread Krzysztof Parzyszek via llvm-branch-commits


@@ -4290,6 +4291,18 @@ class FirConverter : public 
Fortran::lower::AbstractConverter {
 assert(blockId == 0 && "invalid blockId");
 assert(activeConstructStack.empty() && "invalid construct stack state");
 
+// Set target_cpu and target_features attributes to be passed through to 
the
+// llvm.func operation during lowering.
+const llvm::TargetMachine &targetMachine = bridge.getTargetMachine();
+if (auto targetCPU = targetMachine.getTargetCPU(); !targetCPU.empty())
+  func->setAttr("target_cpu",
+mlir::StringAttr::get(func.getContext(), targetCPU));
+
+if (auto targetFeatures = targetMachine.getTargetFeatureString();
+!targetFeatures.empty())
+  func->setAttr("target_features", mlir::LLVM::TargetFeaturesAttr::get(
+   func.getContext(), targetFeatures));

kparzysz wrote:

In FrontendAction we already have the TargetMachine, and we use a part of it in 
the bridge, so this change does not introduce any new dependencies.  Not that 
it would be wrong to do so, but it shows that we already use a part of the 
information from the target machine.  I think it is logical to take it further, 
and include _all_ information from TargetMachine into the lowered MLIR.

https://github.com/llvm/llvm-project/pull/78289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [flang] [Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (PR #78289)

2024-01-16 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz edited 
https://github.com/llvm/llvm-project/pull/78289
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne approved this pull request.

LGTM with some comments, thanks!

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -0,0 +1,24 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
+
+// Make sure that the compile flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module breaks this test.

ldionne wrote:

```suggestion
// Otherwise changing the location of the module would break this test.
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -0,0 +1,24 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
+
+// Make sure that the compile flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module breaks this test.

ldionne wrote:

```suggestion
// Otherwise changing the location of the module would break this test.
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the
+# test. So add these flags before adding the modules.
 substitutions = [
 (s, x + " " + " ".join(additionalCompileFlags))
 if s == "%{compile_flags}"
 else (s, x)
 for (s, x) in substitutions
 ]
 
+if modules:
+_validateModuleDependencies(modules)
+
+# This flag is needed for both modules.
+#moduleCompileFlags.append("-fprebuilt-module-path=%T")
+

ldionne wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the

ldionne wrote:

```suggestion
# Modules need to be built with the same compilation flags as the
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the
+# test. So add these flags before adding the modules.
 substitutions = [
 (s, x + " " + " ".join(additionalCompileFlags))
 if s == "%{compile_flags}"
 else (s, x)
 for (s, x) in substitutions
 ]
 
+if modules:
+_validateModuleDependencies(modules)
+
+# This flag is needed for both modules.
+#moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# The moduleCompileFlags are added to the %{compile_flags}, but
+# the modules need should be built without these flags. So
+# expand the compile_flags and add the expanded value to the
+# build script.
+compileFlags = _getSubstitution("%{compile_flags}", test.config)
+
+# Building the modules needs to happen before the other script
+# commands are executed. Therefore the commands are added to the
+# front of the list.
+if "std.compat" in modules:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} "
+f"{compileFlags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.compat.pcm -c 
%{module}/std.compat.cppm",
+)
+
moduleCompileFlags.append("-fmodule-file=std.compat=%T/std.compat.pcm 
%T/std.compat.pcm")

ldionne wrote:

Let's do this since those are two separate compiler flags:
```suggestion

moduleCompileFlags.extend(["-fmodule-file=std.compat=%T/std.compat.pcm", 
"%T/std.compat.pcm"])
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -52,6 +52,21 @@ def _executeScriptInternal(test, litConfig, commands):
 return (out, err, exitCode, timeoutInfo, parsedCommands)
 
 
+def _validateModuleDependencies(modules):
+for m in modules:
+if m not in ("std", "std.compat"):
+raise RuntimeError(
+f"Invalid module dependency '{m}', only 'std' and 'std.compat' 
are valid"
+)
+
+
+def _getSubstitution(substitution, config):

ldionne wrote:

Suggestion: Use `dsl._getSubstitution` instead. It's kind of an implementation 
detail of that other file, but whatever.

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -0,0 +1,22 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: clang-modules-build
+// UNSUPPORTED: gcc
+
+// XFAIL: has-no-cxx-module-support
+
+// Make sure that the compile flags contain the expected elements.
+// The tests only look for the expected components and not the exact flags.
+// Otherwise changing the location of the module breaks this test.

ldionne wrote:

```suggestion
// Otherwise changing the location of the module would break this test.
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the
+# test. So add these flags before adding the modules.
 substitutions = [

ldionne wrote:

Suggestion: Use `substitutions = dsl._appendToSubstitution(substitutions, 
"%{compile_flags}", " ".join(additionalCompileFlags))`

Same for the modules compile flags.

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the
+# test. So add these flags before adding the modules.
 substitutions = [
 (s, x + " " + " ".join(additionalCompileFlags))
 if s == "%{compile_flags}"
 else (s, x)
 for (s, x) in substitutions
 ]
 
+if modules:
+_validateModuleDependencies(modules)
+
+# This flag is needed for both modules.
+#moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# The moduleCompileFlags are added to the %{compile_flags}, but
+# the modules need should be built without these flags. So
+# expand the compile_flags and add the expanded value to the
+# build script.
+compileFlags = _getSubstitution("%{compile_flags}", test.config)
+
+# Building the modules needs to happen before the other script
+# commands are executed. Therefore the commands are added to the
+# front of the list.
+if "std.compat" in modules:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} "
+f"{compileFlags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.compat.pcm -c 
%{module}/std.compat.cppm",
+)
+
moduleCompileFlags.append("-fmodule-file=std.compat=%T/std.compat.pcm 
%T/std.compat.pcm")
+
+# Make sure the std module is added before std.compat. Libc++'s
+# std.compat module will depend on its std module.  It is not
+# known whether the compiler expects the modules in the order of
+# their dependencies. However it's trivial to provide them in
+# that order.
+script.insert(
+0,
+"%dbg(MODULE std) %{cxx} %{flags} "
+f"{compileFlags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.pcm -c %{module}/std.cppm",
+)
+moduleCompileFlags.append("-fmodule-file=std=%T/std.pcm %T/std.pcm")

ldionne wrote:

```suggestion
moduleCompileFlags.extend(["-fmodule-file=std=%T/std.pcm", 
"%T/std.pcm"])
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the
+# test. So add these flags before adding the modules.
 substitutions = [
 (s, x + " " + " ".join(additionalCompileFlags))
 if s == "%{compile_flags}"
 else (s, x)
 for (s, x) in substitutions
 ]
 
+if modules:
+_validateModuleDependencies(modules)
+
+# This flag is needed for both modules.
+#moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# The moduleCompileFlags are added to the %{compile_flags}, but
+# the modules need should be built without these flags. So
+# expand the compile_flags and add the expanded value to the
+# build script.
+compileFlags = _getSubstitution("%{compile_flags}", test.config)
+
+# Building the modules needs to happen before the other script
+# commands are executed. Therefore the commands are added to the
+# front of the list.
+if "std.compat" in modules:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} "
+f"{compileFlags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.compat.pcm -c 
%{module}/std.compat.cppm",
+)
+
moduleCompileFlags.append("-fmodule-file=std.compat=%T/std.compat.pcm 
%T/std.compat.pcm")
+
+# Make sure the std module is added before std.compat. Libc++'s
+# std.compat module will depend on its std module.  It is not
+# known whether the compiler expects the modules in the order of
+# their dependencies. However it's trivial to provide them in
+# that order.

ldionne wrote:

```suggestion
# Make sure the std module is built before std.compat. Libc++'s
# std.compat module depends on the std module. It is not
# known whether the compiler expects the modules in the order of
# their dependencies. However it's trivial to provide them in
# that order.
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -131,13 +138,65 @@ def parseScript(test, preamble):
 script += preamble
 script += scriptInTest
 
+has_std_module = False
+has_std_compat_module = False
+for module in modules:
+if module == "std":
+has_std_module = True
+elif module == "std.compat":
+has_std_compat_module = True
+else:
+script.insert(
+0,
+f"echo \"The module '{module}' is not valid, use 'std' or 
'std.compat'\"",
+)
+script.insert(1, "false")
+return script
+
+if modules:
+# This flag is needed for both modules.
+moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# Building the modules needs to happen before the other script commands
+# are executed. Therefore the commands are added to the front of the
+# list.
+if has_std_compat_module:
+script.insert(
+0,
+"%dbg(MODULE std.compat) %{cxx} %{flags} %{compile_flags} "
+"-Wno-reserved-module-identifier 
-Wno-reserved-user-defined-literal "
+"--precompile -o %T/std.compat.pcm -c 
%{module}/std.compat.cppm",

ldionne wrote:

Resolving since I created #78310 for this.

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Louis Dionne via llvm-branch-commits


@@ -132,13 +154,62 @@ def parseScript(test, preamble):
 script += scriptInTest
 
 # Add compile flags specified with ADDITIONAL_COMPILE_FLAGS.
+# Modules need to be build with the same compilation flags as the
+# test. So add these flags before adding the modules.
 substitutions = [
 (s, x + " " + " ".join(additionalCompileFlags))
 if s == "%{compile_flags}"
 else (s, x)
 for (s, x) in substitutions
 ]
 
+if modules:
+_validateModuleDependencies(modules)
+
+# This flag is needed for both modules.
+#moduleCompileFlags.append("-fprebuilt-module-path=%T")
+
+# The moduleCompileFlags are added to the %{compile_flags}, but
+# the modules need should be built without these flags. So
+# expand the compile_flags and add the expanded value to the
+# build script.

ldionne wrote:

```suggestion
# The moduleCompileFlags are added to the %{compile_flags}, but
# the modules need to be built without these flags. So expand the
# %{compile_flags} eagerly and hardcode them in the build script.
```

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [DirectX] Move DXIL ResourceKind and ElementType to DXILABI.h. NFC (PR #78225)

2024-01-16 Thread Chris B via llvm-branch-commits

https://github.com/llvm-beanz approved this pull request.

Looks like you angered the clang-format god, but otherwise LGTM.

https://github.com/llvm/llvm-project/pull/78225
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/76246

>From eebe9b2fab5c5eef4776852270bf70af4626cfcb Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 20 Dec 2023 20:43:38 +0100
Subject: [PATCH 1/2] [libc++][modules] Adds module testing.

This adds a new module test infrastructure. This requires tagging tests
using modules. The test runner uses this information to determine the
compiler flags needed to build and use the module.

Currently modules are build per test, which allows testing them for
tests with ADDITIONAL_COMPILE_FLAGS. At the moment only 4 tests use
modules. Therefore the performance penalty is not measurable. If in the
future more tests use modules it would be good to measure the overhead
and determine whether it's acceptable.
---
 libcxx/docs/TestingLibcxx.rst |  9 ++-
 libcxx/modules/std/memory.inc |  2 +
 libcxx/test/libcxx/module_std.gen.py  |  1 +
 libcxx/test/libcxx/module_std_compat.gen.py   |  1 +
 .../libcxx/selftest/modules/no-modules.sh.cpp | 14 
 .../modules/std-and-std.compat-module.sh.cpp  | 22 ++
 .../libcxx/selftest/modules/std-module.sh.cpp | 24 +++
 .../selftest/modules/std.compat-module.sh.cpp | 24 +++
 libcxx/test/std/modules/std.compat.pass.cpp   |  5 +-
 libcxx/test/std/modules/std.pass.cpp  |  5 +-
 libcxx/utils/libcxx/test/features.py  | 12 
 libcxx/utils/libcxx/test/format.py| 71 +++
 libcxx/utils/libcxx/test/modules.py   |  5 +-
 13 files changed, 190 insertions(+), 5 deletions(-)
 create mode 100644 libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
 create mode 100644 
libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
 create mode 100644 libcxx/test/libcxx/selftest/modules/std-module.sh.cpp
 create mode 100644 libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp

diff --git a/libcxx/docs/TestingLibcxx.rst b/libcxx/docs/TestingLibcxx.rst
index e7645cb5885f14e..50ee9d4ee400b45 100644
--- a/libcxx/docs/TestingLibcxx.rst
+++ b/libcxx/docs/TestingLibcxx.rst
@@ -394,7 +394,7 @@ Custom Directives
 ~
 
 Lit has many directives built in (e.g., ``DEFINE``, ``UNSUPPORTED``). In 
addition to those directives, libc++ adds two additional libc++-specific 
directives that makes
-writing tests easier. See `libc++-specific Lit Directives`_ for more 
information about the ``FILE_DEPENDENCIES`` and ``ADDITIONAL_COMPILE_FLAGS`` 
libc++-specific directives.
+writing tests easier. See `libc++-specific Lit Directives`_ for more 
information about the ``FILE_DEPENDENCIES``, ``ADDITIONAL_COMPILE_FLAGS``, and 
``MODULE_DEPENDENCIES`` libc++-specific directives.
 
 .. _libc++-specific Lit Directives:
 .. list-table:: libc++-specific Lit Directives
@@ -417,6 +417,13 @@ writing tests easier. See `libc++-specific Lit 
Directives`_ for more information
  - The additional compiler flags specified by a space-separated list to 
the ``ADDITIONAL_COMPILE_FLAGS`` libc++-specific Lit directive will be added to 
the end of the ``%{compile_flags}``
substitution for the test that contains it. This libc++-specific Lit 
directive makes it possible to add special compilation flags without having to 
resort to writing a ``.sh.cpp`` test (see
`Lit Meaning of libc++ Test Filenames`_), more powerful but perhaps 
overkill.
+   * - ``MODULE_DEPENDENCIES``
+ - ``// MODULE_DEPENDENCIES: std std.compat``
+ - This directive will build the required C++23 standard library
+   modules and add the additional compiler flags in
+   %{compile_flags}. (Libc++ offers these modules in C++20 as an
+   extension.)
+
 
 Benchmarks
 ==
diff --git a/libcxx/modules/std/memory.inc b/libcxx/modules/std/memory.inc
index fba2461732c1b9d..ef89845457fbb9f 100644
--- a/libcxx/modules/std/memory.inc
+++ b/libcxx/modules/std/memory.inc
@@ -156,7 +156,9 @@ export namespace std {
   using std::reinterpret_pointer_cast;
   using std::static_pointer_cast;
 
+#ifndef _LIBCPP_HAS_NO_RTTI
   using std::get_deleter;
+#endif // _LIBCPP_HAS_NO_RTTI
 
   // [util.smartptr.shared.io], shared_ptr I/O
 
diff --git a/libcxx/test/libcxx/module_std.gen.py 
b/libcxx/test/libcxx/module_std.gen.py
index 8e03d6e5b5b5235..a9a05a0cd74e614 100644
--- a/libcxx/test/libcxx/module_std.gen.py
+++ b/libcxx/test/libcxx/module_std.gen.py
@@ -30,6 +30,7 @@
 "%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
 "%{cxx}",
 "%{flags} %{compile_flags}",
+"std",
 )
 
 
diff --git a/libcxx/test/libcxx/module_std_compat.gen.py 
b/libcxx/test/libcxx/module_std_compat.gen.py
index c4792db3d71e624..2866066ccedc89c 100644
--- a/libcxx/test/libcxx/module_std_compat.gen.py
+++ b/libcxx/test/libcxx/module_std_compat.gen.py
@@ -30,6 +30,7 @@
 "%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
 "%{cxx}",
 "%{flags} %{compile_flags}",
+"std.compat",
 )
 
 
diff --git a/libcxx/test/libcxx/selftest/modules/no-modules

[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Mark de Wever via llvm-branch-commits


@@ -52,6 +52,21 @@ def _executeScriptInternal(test, litConfig, commands):
 return (out, err, exitCode, timeoutInfo, parsedCommands)
 
 
+def _validateModuleDependencies(modules):
+for m in modules:
+if m not in ("std", "std.compat"):
+raise RuntimeError(
+f"Invalid module dependency '{m}', only 'std' and 'std.compat' 
are valid"
+)
+
+
+def _getSubstitution(substitution, config):

mordante wrote:

This doesn't work, dsl depends on format. What would work is move this to 
config. I've copied the _appendToSubstitution and will clean up in a follow-up 
commit.

https://github.com/llvm/llvm-project/pull/76246
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [libc++][modules] Adds module testing. (PR #76246)

2024-01-16 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/76246

>From eebe9b2fab5c5eef4776852270bf70af4626cfcb Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Wed, 20 Dec 2023 20:43:38 +0100
Subject: [PATCH 1/3] [libc++][modules] Adds module testing.

This adds a new module test infrastructure. This requires tagging tests
using modules. The test runner uses this information to determine the
compiler flags needed to build and use the module.

Currently modules are build per test, which allows testing them for
tests with ADDITIONAL_COMPILE_FLAGS. At the moment only 4 tests use
modules. Therefore the performance penalty is not measurable. If in the
future more tests use modules it would be good to measure the overhead
and determine whether it's acceptable.
---
 libcxx/docs/TestingLibcxx.rst |  9 ++-
 libcxx/modules/std/memory.inc |  2 +
 libcxx/test/libcxx/module_std.gen.py  |  1 +
 libcxx/test/libcxx/module_std_compat.gen.py   |  1 +
 .../libcxx/selftest/modules/no-modules.sh.cpp | 14 
 .../modules/std-and-std.compat-module.sh.cpp  | 22 ++
 .../libcxx/selftest/modules/std-module.sh.cpp | 24 +++
 .../selftest/modules/std.compat-module.sh.cpp | 24 +++
 libcxx/test/std/modules/std.compat.pass.cpp   |  5 +-
 libcxx/test/std/modules/std.pass.cpp  |  5 +-
 libcxx/utils/libcxx/test/features.py  | 12 
 libcxx/utils/libcxx/test/format.py| 71 +++
 libcxx/utils/libcxx/test/modules.py   |  5 +-
 13 files changed, 190 insertions(+), 5 deletions(-)
 create mode 100644 libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp
 create mode 100644 
libcxx/test/libcxx/selftest/modules/std-and-std.compat-module.sh.cpp
 create mode 100644 libcxx/test/libcxx/selftest/modules/std-module.sh.cpp
 create mode 100644 libcxx/test/libcxx/selftest/modules/std.compat-module.sh.cpp

diff --git a/libcxx/docs/TestingLibcxx.rst b/libcxx/docs/TestingLibcxx.rst
index e7645cb5885f14..50ee9d4ee400b4 100644
--- a/libcxx/docs/TestingLibcxx.rst
+++ b/libcxx/docs/TestingLibcxx.rst
@@ -394,7 +394,7 @@ Custom Directives
 ~
 
 Lit has many directives built in (e.g., ``DEFINE``, ``UNSUPPORTED``). In 
addition to those directives, libc++ adds two additional libc++-specific 
directives that makes
-writing tests easier. See `libc++-specific Lit Directives`_ for more 
information about the ``FILE_DEPENDENCIES`` and ``ADDITIONAL_COMPILE_FLAGS`` 
libc++-specific directives.
+writing tests easier. See `libc++-specific Lit Directives`_ for more 
information about the ``FILE_DEPENDENCIES``, ``ADDITIONAL_COMPILE_FLAGS``, and 
``MODULE_DEPENDENCIES`` libc++-specific directives.
 
 .. _libc++-specific Lit Directives:
 .. list-table:: libc++-specific Lit Directives
@@ -417,6 +417,13 @@ writing tests easier. See `libc++-specific Lit 
Directives`_ for more information
  - The additional compiler flags specified by a space-separated list to 
the ``ADDITIONAL_COMPILE_FLAGS`` libc++-specific Lit directive will be added to 
the end of the ``%{compile_flags}``
substitution for the test that contains it. This libc++-specific Lit 
directive makes it possible to add special compilation flags without having to 
resort to writing a ``.sh.cpp`` test (see
`Lit Meaning of libc++ Test Filenames`_), more powerful but perhaps 
overkill.
+   * - ``MODULE_DEPENDENCIES``
+ - ``// MODULE_DEPENDENCIES: std std.compat``
+ - This directive will build the required C++23 standard library
+   modules and add the additional compiler flags in
+   %{compile_flags}. (Libc++ offers these modules in C++20 as an
+   extension.)
+
 
 Benchmarks
 ==
diff --git a/libcxx/modules/std/memory.inc b/libcxx/modules/std/memory.inc
index fba2461732c1b9..ef89845457fbb9 100644
--- a/libcxx/modules/std/memory.inc
+++ b/libcxx/modules/std/memory.inc
@@ -156,7 +156,9 @@ export namespace std {
   using std::reinterpret_pointer_cast;
   using std::static_pointer_cast;
 
+#ifndef _LIBCPP_HAS_NO_RTTI
   using std::get_deleter;
+#endif // _LIBCPP_HAS_NO_RTTI
 
   // [util.smartptr.shared.io], shared_ptr I/O
 
diff --git a/libcxx/test/libcxx/module_std.gen.py 
b/libcxx/test/libcxx/module_std.gen.py
index 8e03d6e5b5b523..a9a05a0cd74e61 100644
--- a/libcxx/test/libcxx/module_std.gen.py
+++ b/libcxx/test/libcxx/module_std.gen.py
@@ -30,6 +30,7 @@
 "%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
 "%{cxx}",
 "%{flags} %{compile_flags}",
+"std",
 )
 
 
diff --git a/libcxx/test/libcxx/module_std_compat.gen.py 
b/libcxx/test/libcxx/module_std_compat.gen.py
index c4792db3d71e62..2866066ccedc89 100644
--- a/libcxx/test/libcxx/module_std_compat.gen.py
+++ b/libcxx/test/libcxx/module_std_compat.gen.py
@@ -30,6 +30,7 @@
 "%{test-tools}/clang_tidy_checks/libcxx-tidy.plugin",
 "%{cxx}",
 "%{flags} %{compile_flags}",
+"std.compat",
 )
 
 
diff --git a/libcxx/test/libcxx/selftest/modules/no-modules.sh.cpp 

[llvm-branch-commits] [llvm] bcdbff6 - Revert "[AMDGPU] Sign extend simm16 in setreg intrinsic"

2024-01-16 Thread via llvm-branch-commits

Author: Florian Mayer
Date: 2024-01-16T16:37:21-08:00
New Revision: bcdbff65490a76f30624ded5de5e6301e28f1b96

URL: 
https://github.com/llvm/llvm-project/commit/bcdbff65490a76f30624ded5de5e6301e28f1b96
DIFF: 
https://github.com/llvm/llvm-project/commit/bcdbff65490a76f30624ded5de5e6301e28f1b96.diff

LOG: Revert "[AMDGPU] Sign extend simm16 in setreg intrinsic"

Added: 


Modified: 
llvm/lib/Target/AMDGPU/SIInstrInfo.td
llvm/lib/Target/AMDGPU/SOPInstructions.td
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index e0e9aee3ebe0021..7a65f8038c69836 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -767,9 +767,12 @@ class bitextract_imm : SDNodeXFormgetTargetConstant(Bit, SDLoc(N), MVT::i1);
 }]>;
 
-def SIMM16bit : TImmLeaf (Imm) || isUInt<16>(Imm);}],
-  as_i16timm
+def SIMM16bit : ImmLeaf (Imm);}]
+>;
+
+def UIMM16bit : ImmLeaf (Imm);}]
 >;
 
 def i64imm_32bit : ImmLeaf pattern=[]> : 
SOPK_Pseudo <
   pattern>;
 
 def S_SETREG_B32 : S_SETREG_B32_Pseudo <
-  [(int_amdgcn_s_setreg (i32 SIMM16bit:$simm16), i32:$sdst)]> {
+  [(int_amdgcn_s_setreg (i32 timm:$simm16), i32:$sdst)]> {
   // Use custom inserter to optimize some cases to
   // S_DENORM_MODE/S_ROUND_MODE/S_SETREG_B32_mode.
   let usesCustomInserter = 1;

diff  --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
index 99d80b5dd14b338..d2c14f2401fc35a 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
@@ -1433,72 +1433,6 @@ define amdgpu_kernel void 
@test_setreg_set_4_bits_straddles_round_and_denorm() {
   ret void
 }
 
-define amdgpu_ps void @test_63489(i32 inreg %var.mode) {
-; GFX6-LABEL: test_63489:
-; GFX6:   ; %bb.0:
-; GFX6-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
-; GFX6-NEXT:;;#ASMSTART
-; GFX6-NEXT:;;#ASMEND
-; GFX6-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
-;
-; GFX789-LABEL: test_63489:
-; GFX789:   ; %bb.0:
-; GFX789-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
-; GFX789-NEXT:;;#ASMSTART
-; GFX789-NEXT:;;#ASMEND
-; GFX789-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
-;
-; GFX10-LABEL: test_63489:
-; GFX10:   ; %bb.0:
-; GFX10-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
-; GFX10-NEXT:;;#ASMSTART
-; GFX10-NEXT:;;#ASMEND
-; GFX10-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
-;
-; GFX11-LABEL: test_63489:
-; GFX11:   ; %bb.0:
-; GFX11-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
-; GFX11-NEXT:;;#ASMSTART
-; GFX11-NEXT:;;#ASMEND
-; GFX11-NEXT:s_endpgm ; encoding: [0x00,0x00,0xb0,0xbf]
-  call void @llvm.amdgcn.s.setreg(i32 63489, i32 %var.mode)
-  call void asm sideeffect "", ""()
-  ret void
-}
-
-define amdgpu_ps void @test_minus_2047(i32 inreg %var.mode) {
-; GFX6-LABEL: test_minus_2047:
-; GFX6:   ; %bb.0:
-; GFX6-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
-; GFX6-NEXT:;;#ASMSTART
-; GFX6-NEXT:;;#ASMEND
-; GFX6-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
-;
-; GFX789-LABEL: test_minus_2047:
-; GFX789:   ; %bb.0:
-; GFX789-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
-; GFX789-NEXT:;;#ASMSTART
-; GFX789-NEXT:;;#ASMEND
-; GFX789-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
-;
-; GFX10-LABEL: test_minus_2047:
-; GFX10:   ; %bb.0:
-; GFX10-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
-; GFX10-NEXT:;;#ASMSTART
-; GFX10-NEXT:;;#ASMEND
-; GFX10-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
-;
-; GFX11-LABEL: test_minus_2047:
-; GFX11:   ; %bb.0:
-; GFX11-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
-; GFX11-NEXT:;;#ASMSTART
-; GFX11-NEXT:;;#ASMEND
-; GFX11-NEXT:s_endpgm ; encoding: [0x00,0x00,0xb0,0xbf]
-  call void @llvm.amdgcn.s.setreg(i32 -2047, i32 %var.mode)
-  call void asm sideeffect "", ""()
-  ret void
-}
-
 ; FIXME: Broken for DAG
 ; define void @test_setreg_roundingmode_var_vgpr(i32 %var.mode) {
 ;   call void @llvm.amdgcn.s.setreg(i32 4097, i32 %var.mode)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits