blob: 83d40d9cb0edd355f66abffed8875df2110434cf [file] [log] [blame]
//===- TypeSize.cpp - Wrapper around type sizes------------------*- C++ -*-===//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "llvm/Support/TypeSize.h"
#include "llvm/Support/CommandLine.h"
using namespace llvm;
/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
/// using the wrong interface on a scalable vector.
cl::opt<bool> ScalableErrorAsWarning(
"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
cl::desc("Treat issues where a fixed-width property is requested from a "
"scalable type as a warning, instead of an error."),
void llvm::reportInvalidSizeRequest(const char *Msg) {
if (ScalableErrorAsWarning) {
WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
<< "\n";
report_fatal_error("Invalid size request on a scalable vector.");
TypeSize::operator TypeSize::ScalarTy() const {
if (isScalable()) {
"Cannot implicitly convert a scalable size to a fixed-width size in "
"`TypeSize::operator ScalarTy()`");
return getKnownMinValue();
return getFixedValue();