1453: Add in -m32,-m64 configuration to make check-rust r=philberty a=philberty
This is to gate PR's which might break builds on 32bit systems.
Fixes#1439#871
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
1452: transmute: Fix behavior by always performing the raw copy r=CohenArthur a=CohenArthur
This desugars calls to transmute the following way:
`transmute::<T1, T2>(value)`
->
`*((T2 *) &value)`
This always ends up being optimized into a simple copy for small types
and a memcpy for larger types.
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
This desugars calls to transmute the following way:
`transmute::<T1, T2>(value)`
->
`*((T2 *) &value)`
This always ends up being optimized into a simple copy for small types
and a memcpy for larger types.
Co-authored-by: philberty <philip.herron@embecosm.com>
1454: intrinsics: Refactor compilation of intrinsics r=CohenArthur a=CohenArthur
This commit adds helpers around caching, compiling and using intrinsic
functions before extending them with instructions specific to the
intrinsic. We can refactor them further, but this is already a bit
easier to deal with when writing new intrinsics
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Change the CI requirements to have seperate jobs for 64 and 32 bit testing.
It also runs both combinations on the gcc4.8 build job. Bors only requires
the normal build check 64bit job to pass to minimize impact.
This commit adds helpers around caching, compiling and using intrinsic
functions before extending them with instructions specific to the
intrinsic. We can refactor them further, but this is already a bit
easier to deal with when writing new intrinsics
1445: compile: Move and rename `SimpleIntrinsics` -> BuiltinsContext r=CohenArthur a=CohenArthur
This will allow us to use the class for more than just math builtins
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
128 bit integer support is not always available for every GCC arch and we
will need to rely on runtime libraries for these operations in the future.
Addresses #1439
1425: Cleanup frontend entrypoint r=CohenArthur a=CohenArthur
This removes a lot of code that was simply ported from the Go frontend, and forbids the usage of multiple input files.
Addresses #1115
1451: Fix failiure to type inference on unit-structs r=philberty a=philberty
This patch set adds fixes to ensure we can type inference generic unit-structs.
Fixes#1447
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
1444: Handle `rustc_const_{un}stable` properly for intrinsics r=CohenArthur a=CohenArthur
Since extern functions cannot be marked as const (they take no
qualifiers) but some intrinsics are const, while still being `extern
"rust-intrinsic", we need to be able to handle the
`#[rustc_const_stable]` and `#[rustc_const_unstable]` attribute.
Technically, this simply indicates that a certain intrinsic is constant
and can be used in const contexts, such as `size_of` or `offset`.
We also need to mark all const intrinsics with `rustc_const_stable` in
the testsuite.
Closes#1440
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
When we initilize a structure that contains an identifier for the value
which resolves to a generic unit-struct. The unit struct has no fields
but it also contains a reference to a generic parameter which needs to be
infered this updates the code for identifiers to act like a
PathInExpression to infer the generic parameters when its unit struct only.
Fixes#1447
When we have generic unit-structs there are no fields to unify the generic.
This adds a case to ensure we iterate and check these. We might end up
making it always do this for all structs always.
Addresses #1447
There is some dulication here which will eventually go away with the
coercion site refactor which is still a WIP. Here we update the type rules
so that we allow ADT's and tuples to unify and thus fulfill the type
inference rules.
Addresses #1447
1438: Enhance #1426 "Invalid recursive :stmt expansion in fragment specifiers" test case r=philberty a=tschwinge
... that was recently added in #1429 commit 9fc6a27b5c "expand: correctly handles non-macro nodes ...".
- Rename 'macro-issue1403.rs' -> 'macro-issue1426.rs'.
- Get rid of '-w'; expect diagnostic instead.
- Get rid of debugging options not relevant here.
- Get rid of explicit '-O1'; make it a "torture" test case.
- Replace always-matching 'scan-assembler "14"' ("14" appears in the crate name) with directed dump scanning.
- ..., just not for '-O0', where such optimization is not done.
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Since extern functions cannot be marked as const (they take no
qualifiers) but some intrinsics are const, while still being `extern
"rust-intrinsic", we need to be able to handle the
`#[rustc_const_stable]` and `#[rustc_const_unstable]` attribute.
Technically, this simply indicates that a certain intrinsic is constant
and can be used in const contexts, such as `size_of` or `offset`.
We also need to mark all const intrinsics with `rustc_const_stable` in
the testsuite.
1442: testsuite: test for diagnostics shown when a built-in macro does not exist r=CohenArthur a=liushuyu
- testsuite: test for diagnostics shown when a built-in macro does not exist
Co-authored-by: liushuyu <liushuyu011@gmail.com>
... that was recently added in #1429 commit 9fc6a27b5c "expand: correctly handles non-macro nodes ...".
- Rename 'macro-issue1403.rs' -> 'macro-issue1426.rs'.
- Get rid of '-w'; expect diagnostic instead.
- Get rid of debugging options not relevant here.
- Get rid of explicit '-O1'; make it a "torture" test case.
- Replace always-matching 'scan-assembler "14"' ("14" appears in the crate name) with directed dump scanning.
- ..., just not for '-O0', where such optimization is not done.
1437: Array index access does not need to unsize to a slice for access r=philberty a=philberty
When we define the core code for SliceIndex access its possible for an
array to be fully coerced into a slice DST and follow the normal slice
index access which removes support for GCC -Warray-index checks and
generates unnessecary code for array access.
Fixes#1436
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
When we define the core code for SliceIndex access its possible for an
array to be fully coerced into a slice DST and follow the normal slice
index access which removes support for GCC -Warray-index checks and
generates unnessecary code for array access.
Fixes#1436
1435: Update the type hasher to stop duplication of aggregate types r=philberty a=philberty
The hasher we ported was always calling TYPE_HASH which ends up with
DECL_UID which is geneated causing aggregate types keep having a unique
hash which ends up confusing the middle end as two copy's of the same
aggegate type ends up making GCC think there is some kind of type
conversion required here.
Fixes#1434
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
The hasher we ported was always calling TYPE_HASH which ends up with
DECL_UID which is geneated causing aggregate types keep having a unique
hash which ends up confusing the middle end as two copy's of the same
aggegate type ends up making GCC think there is some kind of type
conversion required here.
Fixes#1434
1431: Incremental refactor for better coercion site support r=philberty a=philberty
This is the major refactor to get our coercion site code closer to Rustc.
It introduced several new pieces most notably a refactor to the autoderef
cycle so this can be reused in method resolution and in coercion sites which
allows us to handle deref coercions. It will eventually allow us to get rid
of our bad implementation in rust-tyty-coercion.h which is just messy now.
Fixes#1198
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
1433: Fix bad transmute for aggregate types r=philberty a=philberty
This changes the CONVERT_EXPR to use the same ```*(foo*)&bar``` style cast from
the c front-end to handle the case of:
```
int a[1];
int b = (int)a;
```
Which is converted into:
```
int b = *(int*)&a;
```
which the constant folders can turn directly into int b = a[0];
Fixes#1432
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
This changes the CONVERT_EXPR to use the same *(foo*)&bar style cast from
the c front-end to handle the case of:
int a[1];
int b = (int)a;
Which is converted into:
int b = *(int*)&a;
which the constant folders can turn directly into int b = a[0];
Fixes#1432
This is an incremental approach to get our coercion sites more acurate to
rustc. This allows us to support coercions which require a deref by sharing
the code from the autoderef cycle. The eventual goal here will allow us to
remove the rust-tyty-coercion rules which is messy and cannot handle logic
such as DST's very well.
Fixes#1198
Similar to the fix in 405d9f1d13 when we have
arguments that our method calls. The id used for storing the autoderef
mappings being the method call itself rather than the receiver argument
it will cause an ICE when we are type checking all arguments for the case
of:
Foo(a, bar.baz(123))
This ensures we store the autoderef mappings directly on the reciever
instead.
Imagine the call expression:
Foo(a+b)
But the a+b is an operator overload of the assignment operation. We store
the autoderef coercions on the HIR id of the plus_expression here which is
going to conflict with the id used to store the autoderef coercions the
argument a+b. So this patch changes that all autoderef coercions store the
autoderef for the implicit method call on the hirid of the lvalue hirid
which in this case is 'a'. This means we won't conflict and cause an ICE
in this case.
This brings out the indirect expression out of our gcc wrapper, it also
just simplifies down to the normal build_indirect_expr_loc calls. Which
does not require specifiying the type since we can reuse TREE_TYPE. This
also simplifies the address_expression to just address_expr_with_loc and
grabs the type from TREE_TYPE as well.
In order to fully support coercion sites we need a single place in order to
implement the logic. This refactors all the coercion calls to have a single
TypeCheckBase::coercion_site(lhs, rhs, location). Eventually we will do
something similar for unifications and casts so we can improve our
diagnostics.
The autoderef cycle is used to coerce/select apropriate methods during
method resolution. This same cycle of autoderef is also used as coercion
sites. In order to avoid duplicating the logic this extracts out a useful
base class that can be implemented to support this elsewhere.
... a macro is now considered builtin macro only if it has
rustc_builtin_macro attribute. This also allows overriding macro
definition with the same name as the builtin ones.
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
When inserting external items, it's interesting to also be able to
lookup the extern block they were defined in, similarly to impl items.
This is useful to know the ABI or other specifiers of the block the item
has been declared in.
1421: expand: further improves the handling of recursive macros r=CohenArthur a=liushuyu
- expand: further improves the handling of recursive macros.
Now all the attribute visitor that expands the macro fragment will recursively expand the macro using the unified expanding function `expand_macro_fragment_recursive` instead of expanding the fragment only once.
Fixes#1403
Co-authored-by: liushuyu <liushuyu011@gmail.com>
... now all the attribute visitor that expands the
macro fragment will recursively expand the macro
using the unified expanding function
`expand_macro_fragment_recursive` instead of expanding
the fragment only once.
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>