Skip to content

Commit 0d20709

Browse files
committed
Add MissingFeatures tracker
1 parent d0c2866 commit 0d20709

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===---- MissingFeatures.h - Checks for unimplemented features -*- 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+
// This file introduces some helper classes to guard against features that
10+
// CIR dialect supports that we do not have and also do not have great ways to
11+
// assert against.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#ifndef CLANG_CIR_MISSINGFEATURES_H
16+
#define CLANG_CIR_MISSINGFEATURES_H
17+
18+
namespace cir {
19+
20+
// As a way to track features that haven't yet been implemented this class
21+
// explicitly contains a list of static fns that will return false that you
22+
// can guard against. If and when a feature becomes implemented simply changing
23+
// this return to true will cause compilation to fail at all the points in which
24+
// we noted that we needed to address. This is a much more explicit way to
25+
// handle "TODO"s.
26+
struct MissingFeatures {
27+
// Address space related
28+
static bool addressSpace() { return false; }
29+
30+
// Unhandled global/linkage information.
31+
static bool opGlobalDSOLocal() { return false; }
32+
static bool opGlobalThreadLocal() { return false; }
33+
static bool opGlobalConstant() { return false; }
34+
static bool opGlobalAlignment() { return false; }
35+
static bool opGlobalLinkage() { return false; }
36+
};
37+
38+
} // namespace cir
39+
40+
#endif // CLANG_CIR_MISSINGFEATURES_H

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "mlir/Target/LLVMIR/Export.h"
2626
#include "mlir/Transforms/DialectConversion.h"
2727
#include "clang/CIR/Dialect/IR/CIRDialect.h"
28+
#include "clang/CIR/MissingFeatures.h"
2829
#include "llvm/IR/Module.h"
2930
#include "llvm/Support/TimeProfiler.h"
3031

@@ -62,12 +63,18 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
6263
// This is the LLVM dialect type.
6364
const mlir::Type llvmType = getTypeConverter()->convertType(cirSymType);
6465
// FIXME: These default values are placeholders until the the equivalent
65-
// attributes are available on cir.global ops.
66+
// attributes are available on cir.global ops.
67+
assert(!cir::MissingFeatures::opGlobalConstant());
6668
const bool isConst = false;
69+
assert(!cir::MissingFeatures::addressSpace());
6770
const unsigned addrSpace = 0;
71+
assert(!cir::MissingFeatures::opGlobalDSOLocal());
6872
const bool isDsoLocal = true;
73+
assert(!cir::MissingFeatures::opGlobalThreadLocal());
6974
const bool isThreadLocal = false;
75+
assert(!cir::MissingFeatures::opGlobalAlignment());
7076
const uint64_t alignment = 0;
77+
assert(!cir::MissingFeatures::opGlobalLinkage());
7178
const mlir::LLVM::Linkage linkage = mlir::LLVM::Linkage::External;
7279
const StringRef symbol = op.getSymName();
7380
std::optional<mlir::Attribute> init = op.getInitialValue();

0 commit comments

Comments
 (0)