Commit Graph

1069 Commits

Author SHA1 Message Date
Joe Groff
4c0ebedc6a SIL: Add SILGlobalAddrInst.
Like GlobalAddrInst, but for SILGlobalVariables. These would become the same instruction when SILGlobalVariable can replace AST-level global references.

Swift SVN r10510
2013-11-16 00:50:18 +00:00
Joe Groff
19457c12ea Give Builtin.Word an abstract size.
Instead of hardcoding Builtin.Word to be an alias for Builtin.Int64, make it its own type of abstract pointer width.

- Change BuiltinIntegerType's width representation to accommodate abstract widths.

- In the AST and in SIL, store values of the types as the greatest supported size for the abstract width (64 bits for a pointer).

- Add some type safety to the ([sz]ext|trunc)(OrBitCast)? builtins that they're used appropriately given the upper and lower bounds of the abstract sizes they're working with.

- Now that Builtin.Word is a distinct type, give it its own mangling.

- In IRGen, lower pointer-sized BuiltinIntegerType appropriately for the target, and truncate lowered SIL values if necessary.

Fixes <rdar://problem/15367913>.

Swift SVN r10467
2013-11-14 19:56:26 +00:00
Chris Lattner
425819ac07 Change the SIL string_literal instruction to produce three results
(the same way alloc_box returns two) instead of returning a tuple.

This eliminates a ton of tuple_extract instructions, which just
bloat the generated SIL.  This resolves rdar://15378135.



Swift SVN r10416
2013-11-13 06:43:09 +00:00
John McCall
93dfaa6bf4 Make everything getting a TypeInfo declare whether it's
working with a SIL-lowered or SIL-unlowered type.

Swift SVN r10067
2013-11-09 01:41:16 +00:00
Chris Lattner
82567f9ffb SILValue is just a wrapper around its ValueAndResultNumber. Derive
the number of low bits available in it from the #bits in ValueAndResultNumber,
instead of computing it independently.


Swift SVN r9922
2013-11-04 17:54:42 +00:00
Chris Lattner
0f3c949000 inline emitStringLiteral into its only caller.
Swift SVN r9920
2013-11-04 17:43:49 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Adrian Prantl
459db73092 Debug info: Move the logic for emitting type metadata arguments to
GenProto, and emit both the mangled name and the type variable used by the
programmer for archetypes.
Fixes <rdar://problem/15346134> The $swift.type metadata arguments do not show up anymore

Swift SVN r9844
2013-10-31 04:50:33 +00:00
Joe Groff
98f0e6e395 IRGen: Lower SIL 'undef' to IR 'undef'(s).
For every 'undef' we see of some SILType, build an appropriate LoweredValue for it out of LLVM undef values.

Swift SVN r9795
2013-10-30 17:00:21 +00:00
Adrian Prantl
ebeeebf116 Debug info: Reset the debug location after emitting the initial phi-node
locations for a more coherent line table. Relax testcase.

Swift SVN r9745
2013-10-28 23:14:45 +00:00
Adrian Prantl
5bbe0afb9f Debug info: Properly handle the function prologue in the line table.
Introduces a new flag in SILLocation: InPrologue to mark instructions
that setup the stack and allocate storage for local variables/arguments.

Fixes rdar://problem/15290023: Breakpoint set on prologue - crash ensues.

Swift SVN r9686
2013-10-26 00:12:20 +00:00
Dmitri Hrybenko
80d753d0ab Portability: use std::make_tuple instead of relying on a libc++ extension (an
implicit constructor in std::tuple)


Swift SVN r9615
2013-10-23 06:17:28 +00:00
Joe Groff
b8ec74f1c7 IRGen: Lower CondFailInst.
Swift SVN r9593
2013-10-22 16:08:25 +00:00
Joe Groff
00dcdf394f SIL: Introduce CondFailInst.
This instruction will conditionally trigger a runtime failure if its operand is true.

Swift SVN r9588
2013-10-22 15:53:04 +00:00
Chris Lattner
91c7cea310 Remove the SILModule& argument from a few methods in SILInstruction.h.
Instructions know which module they came from, so there is no need to
pass it in.



Swift SVN r9584
2013-10-22 11:06:50 +00:00
Joe Groff
61360ba7a4 SIL: Remove ConvertCCInst.
Swift SVN r9577
2013-10-22 03:16:27 +00:00
Adrian Prantl
37a0827386 Debug info: fix a bug with indirect values by using enums for type-safety.
rdar://problem/15248201

Swift SVN r9463
2013-10-17 21:16:42 +00:00
Adrian Prantl
65dc82d530 Debug info: emit Archetypes and their conforming protocols.
Fixes rdar://problem/15209779 and rdar://problem/15211793.

Swift SVN r9422
2013-10-16 22:14:37 +00:00
Adrian Prantl
2a8d4bb16c Do not emit debug info for external references.
Swift SVN r9421
2013-10-16 22:14:33 +00:00
Joe Groff
d273b799e3 IRGen: Emit downcasts to ObjC protocol types.
Use objc_getProtocol to derive a reference to the Protocol* for each required conformance, then pass the array off to a to-be-written dynamicCastObjCProtocol(Un)?Conditional entry point that will do all of the conformsToProtocol checks.

Swift SVN r9397
2013-10-16 01:28:59 +00:00
Joe Groff
5b1bd6ed79 AST: Add checked cast kinds for concrete-to-archetype and concrete-to-unrelated-existential casts.
No typechecker or IRGen support just yet.

Swift SVN r9392
2013-10-16 00:10:11 +00:00
Adrian Prantl
7f688c806b Debug info: attach more appropriate locations to the phi nodes
at the beginning of each basic block.
rdar://15189057

Swift SVN r9327
2013-10-14 21:23:38 +00:00
Adrian Prantl
adc913b73c Debug info: The end of the prologue should point to the opening brace.
Some refactoring the separate the needs of the line table versus decls.
rdar://problem/15204469

Swift SVN r9224
2013-10-11 22:15:10 +00:00
Adrian Prantl
9ad9548388 Debug info: Update the inout testcase and emit debug information for
unboxed [inout] arguments.

Swift SVN r9187
2013-10-11 01:00:46 +00:00
Adrian Prantl
5325fd35e5 Debug info: Don't make byref types indirect.
Swift SVN r9160
2013-10-10 18:47:04 +00:00
John McCall
b880e60100 Remove SILFunctionTypeInfo in favor of SILFunctionType.
We still don't actually use this as a type, however.

Swift SVN r9091
2013-10-09 20:55:55 +00:00
Adrian Prantl
37bb48afb0 Debug info: Create debug type info for box-allocated types by using their
Decl. This should allow us to emit debug info for boxed generic types.

rdar://problem/15180622

Swift SVN r9071
2013-10-09 18:25:18 +00:00
Pete Cooper
f9c6bf0630 Initial framework for generating Axle metadata. This currently only supports the function level metadata. Argument and result metadata to come later
Swift SVN r9061
2013-10-09 16:54:28 +00:00
Adrian Prantl
627fec7f41 Debug info: fix scoping for boxed values that get promoted to stack
allocated values. Fixes rdar://problem/15035350

Swift SVN r9044
2013-10-09 01:01:32 +00:00
Stephen Lin
a6108dbd48 Rename FunctionRefInst::getFunction() and BuiltinFunctionRefInst::getFunction() to FunctionRefInst::getReferencedFunction() and BuiltinFunctionRefInst::getReferencedFunction() to avoid shadowing SILInstruction::getFunction().
Swift SVN r8929
2013-10-04 20:26:41 +00:00
Adrian Prantl
8808d48578 Debug info: emit captured variables in closures. rdar://problem/15035486
Swift SVN r8859
2013-10-02 22:46:03 +00:00
Adrian Prantl
0bd4357b1f Debug info: Emit shadow copies of boxed value's addresses in an alloca at
-O0 so the register allocator will not elide its DBG_VALUE.

Swift SVN r8798
2013-09-30 23:34:15 +00:00
Joe Groff
82a18333ed SIL: Purge SpecializeInst.
Make ApplyInst and PartialApplyInst directly take substitutions for generic functions instead of trying to stage out substitutions separately. The legacy reasons for doing this are gone.

Swift SVN r8747
2013-09-28 00:15:45 +00:00
Adrian Prantl
61b5d055ef Debug info: allow for boxed arguments. rdar://problem/15035486
Swift SVN r8713
2013-09-27 00:31:20 +00:00
Joe Groff
a2672e9313 SIL: Turn conditional checked casts into a branch instruction.
Replace the existing suite of checked cast instructions with:

- unconditional_checked_cast, which performs an unconditional cast that aborts on failure (like the former downcast unconditional); and
- checked_cast_br, which performs a conditional pass and branches on whether the cast succeeds, passing the result to the true branch as an argument.

Both instructions take a CheckedCastKind that discriminates the different casting modes formerly discriminated by instruction type. This eliminates a source of null references in SIL and eliminates null SIL addresses completely.

Swift SVN r8696
2013-09-26 18:24:44 +00:00
Joe Groff
cbfe3710f6 SIL: Rename the 'isObjC' SILDeclRef specifier to 'isForeign'.
Doug pointed out that 'isObjC' incorrectly excludes C functions, for which we'll also need to be able to independently reference Swift and foreign entries.

Swift SVN r8669
2013-09-25 21:59:03 +00:00
Adrian Prantl
6009987432 Debug info: implement support for shadow-copied [byref] arguments.
This patch has a negative line balance -- those are my favorite!

Swift SVN r8655
2013-09-25 20:17:21 +00:00
Adrian Prantl
c4ece4ec9f Revisit scopes and locations in the light of SIL-based transparent inlining.
Swift SVN r8625
2013-09-25 16:14:47 +00:00
Doug Gregor
e6f47a6e2d IRGen for dynamic subscripting operations.
Swift SVN r8612
2013-09-24 22:28:36 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00
Doug Gregor
903a4d2ea1 Implement SILGen/IRGen support for dynamic lookup that resolves to properties.
Swift SVN r8521
2013-09-20 22:15:03 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
John McCall
7954960797 Add 'copy_value' and 'destroy_value' operations to destroy
entire aggregates at once.

This has three worth effects:
  - It significantly decreases the amount of SIL required
    for these operations.
  - It makes it far easier for IR-gen to choose efficient
    patterns of destruction, e.g. calling a single entrypoint
    or recognizing that it can just use the runtime 'release'
    entrypoints.
  - It makes it easier to recognize and optimize aggregate
    copy/destroy operations.
It does make SROA-like tasks a bit more challenging.  The
intent is to give TypeLowering a way to expand these into
their primitive behavior.

Swift SVN r8465
2013-09-19 22:14:55 +00:00
Doug Gregor
4a377575f8 IRGen support for dynamic method lookup of static methods.
Swift SVN r8301
2013-09-16 22:27:53 +00:00
Adrian Prantl
6fb78ed5e5 Debug info: Add initial support for boxed values on the heap.
Swift SVN r8221
2013-09-13 23:14:52 +00:00
Adrian Prantl
ba105c5705 Debug info: Emit byref parameter types as reference types.
Also scan store instructions for byref arguments.

Swift SVN r8209
2013-09-13 20:58:23 +00:00
Doug Gregor
c2c367b12a Pass the right selector to swift_objcRespondsToSelector().
With this, we're correctly lowering the dynamic_method_br instruction
to IR, which allows us to query the existence of an instance method on
a value of type DynamicLookup and, if it's there, call it via the
closure stored in the optional. Part of <rdar://problem/14397505>.


Swift SVN r8205
2013-09-13 17:12:32 +00:00
Adrian Prantl
25f3bfe202 Debug info: Implement [byref] function arguments. rdar://problem/14949469
Swift SVN r8197
2013-09-13 16:03:45 +00:00
Chris Lattner
7c8ae9352a Add a new "mark_function_escape" instruction that will be used to mark the
escape point of function definitions that "close" over global variables.



Swift SVN r8152
2013-09-12 18:31:00 +00:00
Joe Groff
59b3ecc3a2 IRGen: Bind the destination BB argument for dynamic_lookup_br.
This is kind of gross because we want the BB argument to be lowered to an ObjCMethod abstraction rather than a concrete explosion of PHI nodes. For now, assume that there won't be other predecessors to a dynamic_method_br's destinations and clobber the BB argument's PHI node lowering, replacing it with an ObjCMethod. This is hacky but unblocks Doug's dynamic lookup work, and avoids having to create an ObjCMethod-to-explosion thunk in the (currently 100%, probably always 99.99%) case where the branches have single predecessors.

Swift SVN r8150
2013-09-12 17:52:01 +00:00