Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConstantInt should overload getType() to return an IntegerType* #1492

Closed
nlewycky opened this issue Jan 17, 2007 · 5 comments
Closed

ConstantInt should overload getType() to return an IntegerType* #1492

nlewycky opened this issue Jan 17, 2007 · 5 comments
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:core

Comments

@nlewycky
Copy link
Contributor

Bugzilla Link 1120
Resolution FIXED
Resolved on Feb 22, 2010 12:54
Version trunk
OS All
Blocks #1415

Extended Description

If a ConstantInt user wants the number of bits in the int, they have to call
getType, then cast the Type* to an IntegerType*. Instead, it should be possible
to retrieve the IntegerType* directly from ConstantInt.

This is difficult because ConstantInt doesn't actually keep the IntegerType*
internally, nor does it require one on construction, etc. This will probably
cause residual effects throughout LLVM, but it shouldn't be very hard to clean up.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 17, 2007

I just emailed Chris about this. There are actually several related changes needed:

  1. Make Type::Int1Ty, Type::Int8Ty, etc. declared as IntegerType*
    in Type.h instead of Type.h. This will also requires changes in
    Type.cpp to the instantiation macros.
  2. Add a ConstantInt::getType() method similar to
    ConstantArray::getType() that returns IntegerType instead of
    defaulting to Value::getType() which returns Type*.
  3. Change ConstantInt::get(const Type*, uint64_t Val) -> have an
    IntegerType argument. You must use IntegerType to instantiate a
    ConstantInt.
  4. Move getIntegerTypeMask from Type class to IntegerType class and
    rename it getBitMask.
  5. Adjust the rest of LLVM for the 4 changes above.

I have already assigned Sheng to do this. I'm assigning this PR to him so
we can track his progress with it.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 17, 2007

Re: this:

This is difficult because ConstantInt doesn't actually keep the IntegerType*
internally, nor does it require one on construction, etc. This will probably
cause residual effects throughout LLVM, but it shouldn't be very hard to
clean up.

That's not quite right. ConstantInt is a Constant which is a Value which has
Type. All Values in LLVM have types and ConstantInt isn't an exception. There
are three ways to construct a ConstantInt:

static ConstantInt *get(const Type *Ty, int64_t V);
static inline ConstantInt *getTrue();
static inline ConstantInt *getTrue();

The first requires a Type and item 3 on my list above requires that to change to
IntegerType*. For the other two, the type is Type::Int1Ty.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 17, 2007

Sheng: this needs to be your highest priority right now as it is "Phase 2" work.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 17, 2007

As Chris suggested, the #​3 will not be done. Because it will cause much change
throughout llvm but get no real benefit.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 19, 2007

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
…ca1085dfb1b20c842b0ffb

Backport [lldb] Only set the executable module for a target once and fix build error
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-quality llvm:core
Projects
None yet
Development

No branches or pull requests

2 participants