[llvm] [DirectX backend] emits metadata for DXIL version. (PR #88350)

Chris B via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 09:52:36 PDT 2024


================
@@ -0,0 +1,117 @@
+//===- DXIL.cpp - Abstractions for DXIL constructs ------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Utils/DXIL.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+using namespace llvm::dxil;
+
+static Error errInvalid(const char *Msg) {
+  return createStringError(std::errc::invalid_argument, Msg);
+}
+
+template <typename... Ts>
+static Error errInvalid(const char *Fmt, const Ts &...Vals) {
+  return createStringError(std::errc::invalid_argument, Fmt, Vals...);
+}
+
+Expected<DXILVersion> DXILVersion::get(Module &M) {
+  Triple TT(Triple::normalize(M.getTargetTriple()));
----------------
llvm-beanz wrote:

Normalizing the triple should be sufficient for identifying the sub architecture. @bharadwajy's PR (https://github.com/llvm/llvm-project/pull/90809) needed to be reverted, but when it re-lands this should radically simplify.

https://github.com/llvm/llvm-project/pull/88350


More information about the llvm-commits mailing list