CIRCT 20.0.0git
Loading...
Searching...
No Matches
APInt.cpp
Go to the documentation of this file.
1//===- APInt.h - CIRCT Lowering Options -------------------------*- 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// Utilities for working around limitations of upstream LLVM APInts.
10//
11//===----------------------------------------------------------------------===//
12
13#include "circt/Support/APInt.h"
14#include "llvm/ADT/APSInt.h"
15
16using namespace circt;
17
18APInt circt::sextZeroWidth(APInt value, unsigned width) {
19 return value.getBitWidth() ? value.sext(width) : value.zext(width);
20}
21
22APSInt circt::extOrTruncZeroWidth(APSInt value, unsigned width) {
23 return value.getBitWidth()
24 ? value.extOrTrunc(width)
25 : APSInt(value.zextOrTrunc(width), value.isUnsigned());
26}
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
APSInt extOrTruncZeroWidth(APSInt value, unsigned width)
A safe version of APSInt::extOrTrunc that will NOT assert on zero-width signed APSInts.
Definition APInt.cpp:22
APInt sextZeroWidth(APInt value, unsigned width)
A safe version of APInt::sext that will NOT assert on zero-width signed APSInts.
Definition APInt.cpp:18