Add a test case to ensure that llvm-upgrade retains correct semantics
for the previous definition of "cast to bool" which compared against null.
llvm-svn: 32812
Revise the upgrade parser to keep track of types more faithfully and use
this information to resolve name conflicts resulting from collapsed type
planes. The type planes have collapsed because the integer types are now
signless so that uint and int became i32. Where two planes existed for uint
and int, only i32 exists. Any variable names depending on the type planes
to pmake the identifier unique would cause a conflict. This patch resolves
that conflict for many but not all cases.
Situations involving the integer types and pointers to them are handled
by this patch. However, there are corner cases that are not handled
well, such as:
%t1 = type { uint, int }
%t2 = type { int, uint }
void %myfunc(%t1* one, %t2* two) {
%var = load %t1* one
%var = load %t2* two
}
In the scenario above, %t1 and %t2 are really the same type: { i32, i32 }
Consequently attempting to name %var twice will yield a redefinition error
when assembled.
While this patch is sufficien to allow the llvm/test suite to pass, More
work needs to be to complete the handling of these corner cases.
llvm-svn: 32810
Update for signless integer types:
1. Replace [us]byte with i8
2. Replace [u]short with i16
3. Replace [u]int with i32
4. Replace [u]long with i64
5. Document the "define" keyword and use it in all examples.
6. Document parameter attributes and how they affect function types.
llvm-svn: 32791
Update the test suite to accommodate the change from signed integer types
to signless integer types. The changes were of only a few kinds:
1. Make sure llvm-upgrade is run on the source which does the bulk of the
changes automatically.
2. Change things like "grep 'int'" to "grep 'i32'"
3. In several tests bitcasting caused the same name to be reused in the
same type plane. These had to be manually fixed. The fix was (generally)
to leave the bitcast and provide the instruction with a new name. This
should not affect the semantics of the test. In a few cases, the
bitcasts were known to be superfluous and irrelevant to the test case
so they were removed.
4. One test case uses a bytecode file which needed to be updated to the
latest bytecode format.
llvm-svn: 32789
Three changes:
1. Convert signed integer types to signless versions.
2. Implement the @sext and @zext parameter attributes. Previously the
type of an function parameter was used to determine whether it should
be sign extended or zero extended before the call. This information is
now communicated via the function type's parameter attributes.
3. The interface to LowerCallTo had to be changed in order to accommodate
the parameter attribute information. Although it would have been
convenient to pass in the FunctionType itself, there isn't always one
present in the caller. Consequently, a signedness indication for the
result type and for each parameter was provided for in the interface
to this method. All implementations were changed to make the adjustment
necessary.
llvm-svn: 32788
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int -> Int32
4. [U]Long -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
and other methods related to signedness. In a few places this warranted
identifying the signedness information from other sources.
llvm-svn: 32785
Don't attempt to parse both the old and new grammars. It is near impossible
to get it right. Remove support for the new define keyword and don't
attempt to insert parameter attributes because there isn't enough
contextual information for it.
llvm-svn: 32784
Update for signless integer types and parameter attribute implementation.
Of significant note:
1. This changes the bytecode format yet again.
2. There are 1/2 as many integer type planes (this is a good thing)
3. GEP indices now use only 1 bit to identify their type which means
more GEP instructions won't be relegated to format 0 (size win)
4. Parameter attributes are implemented but currently being stored
verbosely for each function type. Some other day this needs to be
optimized for size.
llvm-svn: 32783
Major reorganization. This patch introduces the signedness changes for
the new integer types (i8, i16, i32, i64) which replace the old signed
versions (ubyte, sbyte, ushort, short, etc). This patch also implements
the function type parameter attributes feature. Together these conspired
to introduce new reduce/reduce errors into the grammar. Consequently, it
was necessary to introduce a new keyword into the grammar in order to
disambiguate. Without this, yacc would make incorrect shift/reduce and
reduce/reduce decisions and fail to parse the intended assembly.
Changes in assembly:
1. The "implementation" keyword is superfluous but still supported. You
can use it as a sentry which will ensure there are no remaining up
reference types. However, this is optional as those checks are also
performed elsewhere.
2. Parameter attributes are now implemented using an at sign to
indicate the attribute. The attributes are placed after the type
in a function declaration or after the argument value in a function
call. For example:
i8 @sext %myfunc(i16 @zext)
call i8 @sext %myfunc(i16 @zext %someVal)
The facility is available for supporting additional attributes and
they can be combined using the @(attr1,attr2,attr3) syntax. Right
now the only two supported are @sext and @zext
3. Functions must now be defined with the "define" keyword which is
analagous to the "declare" keyword for function declarations. The
introduction of this keyword disambiguates situations where a
named result type is confused with a new type or gvar definition.
For example:
%MyType = type i16
%MyType %func(%MyType) { ... }
With the introduction of optional parameter attributes between
the function name and the function result type, yacc will pick
the wrong rule to reduce unless it is disambiguated with "define"
before the function definition, as in:
define %MyType @zext %func(%MyType %someArg) { ... }
llvm-svn: 32781
Add a new feature to FunctionType, Parameter Attributes. This allows tags
such as "sext" and "zext" to be associated with a faunction's arguments
or return type. This allows signedness information to be carried forward
from the frontend to the backend for arguments and result types.
llvm-svn: 32776
depend on the compiler. This works around problems in the Stacker runtime
when the CFE changes in such a way that the assembly file needs to be
updated.
llvm-svn: 32773
Fix several bugs and update for new assembly syntax. Changes made include:
1. Fixing rules for icmp/fcmp instructions to not require a closing paren
at the end. This was a cut-and-paste error from a previous commit.
2. Changing things like Out << " " to Out << ' '
3. Adding the "define" keyword for function definitions
4. Adding support for packed structures
llvm-svn: 32771
Remove all grammar conflicts from assembly parsing. This change involves:
1. Making the "type" keyword not a primitive type (removes several
reduce/reduce conflicts)
2. Being more specific about which linkage types are allowed for functions
and global variables. In particular "appending" can no longer be
specified for a function. A differentiation was made between the various
internal and external linkage types.
3. Introduced the "define" keyword which is now required when defining a
function. This disambiguates several cases where a named function return
type could get confused with the definition of a new type. Using the
keyword eliminates all shift/reduce conflicts and the remaining
reduce/reduce conflicts.
These changes are necessary to implement the function parameter attributes
that will be introduced soon. Adding the function parameter attributes in
the presence of the shift/reduce and reduce/reduce conflicts led to severe
ambiguities that caused the parser to report syntax errors that needed to
be resolved. This patch resolves them.
llvm-svn: 32770