Commit Graph

292 Commits

Author SHA1 Message Date
Manman Ren
fb4ded9a72 SIL Parser: parse super_method and autorelease_return.
In parseSILDeclRef, when searching for the first component of the
fully-qualified name, we use UnqualifiedLookup to look through the imports.
Before this commit, only the current module is searched.
Testing cases are generated from a simple swift program using NSObject.


Swift SVN r6871
2013-08-03 01:20:25 +00:00
John McCall
796e434f63 Make "isTake" and "isInitialization" flags type-safe.
Swift SVN r6860
2013-08-02 22:38:14 +00:00
John McCall
d7a72b93e1 Add ref_to_unowned and unowned_to_ref bitcast instructions.
Swift SVN r6838
2013-08-02 08:31:01 +00:00
John McCall
00a940ac1b Rename weak_retain to unowned_retain and change it to
require the correct [unowned] type as an argument.

Swift SVN r6825
2013-08-02 00:02:09 +00:00
Anna Zaks
2c529eb21a [SILParser] Parse basic block arguments in branch instructions
Added types when printing these args in the SIL printer.

As a side effect, I've removed the assertions that check
that we have the correct number of arguments in the Branch instruction
creation routines. The reason is that we do not have a complete block when
parsing and creating the branch instruction and it is possible to add
arguments to a basic block after creation. The assertion will be checked
by the SIL verifier.

Swift SVN r6818
2013-08-01 21:32:05 +00:00
Anna Zaks
c12b826816 [SILParser] Run SILVerifier after parsing SIL.
Swift SVN r6817
2013-08-01 21:32:03 +00:00
Joe Groff
ba774364f1 SIL: Have SILModules track their SILStage.
Modules can be in either 'Raw' or 'Canonical' form, with different invariants on each. We don't actually distinguish those invariants yet, but this patch adds the field to SILModule and adds a "sil_stage" declaration to SIL printer/parser syntax.

Swift SVN r6793
2013-08-01 00:58:31 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Joe Groff
cc45633714 SIL: Don't print instruction labels for value-less instructions.
Swift SVN r6756
2013-07-30 22:33:34 +00:00
Doug Gregor
3d0c2e2612 Record the protocols and superclass for generic parameters.
This allows us to use getProtocols() rather than getInherited()
wherever we're dealing with generic parameters and associated types.


Swift SVN r6683
2013-07-29 14:27:25 +00:00
Joe Groff
24dc1cfad7 SIL: Remove the redundant associated_metatype instruction.
Its behavior was exactly the same in IRGen as 'metatype' on the associated type. Managing type metadata should be IRGen's job.

Swift SVN r6677
2013-07-27 04:13:59 +00:00
Joe Groff
1300efb8fb SIL: Represent float_literal values with bitwise representations.
This way we don't need to deal with the inaccuracy of decimal float literals. While we're here, modify the in-memory representation of IntegerLiteralInst and FloatLiteralInst to save the word array of the APInt instead of round-tripping through plain text.

Swift SVN r6676
2013-07-27 03:57:14 +00:00
Joe Groff
6b779cc642 SIL: Spell all non-SILFunction Swift decl references with '#'.
Reserve '@' as the SILFunction introducer, and use '#' when referencing Swift decls (like with SILConstants).

Swift SVN r6563
2013-07-24 22:10:52 +00:00
Joe Groff
398cbba5be Rename SILConstant to SILDeclRef.
"SILConstant" doesn't really describe its role in SIL anymore, which is to provide a reference to a Swift declaration in a SIL instruction, such as a method or nominal type field.

Swift SVN r6559
2013-07-24 21:21:31 +00:00
John McCall
e668ff914f Add parsing and IR-gen for weak_retain and weak_release.
Swift SVN r6492
2013-07-23 06:28:51 +00:00
Chris Lattner
a83cdb77ae teach silparser to parse the unreachable instruction
Swift SVN r6489
2013-07-23 02:50:37 +00:00
Chris Lattner
cccf26b9b0 rename [de]alloc_var -> [de]alloc_stack in the printed and parsed sil syntax.
Swift SVN r6389
2013-07-19 21:18:20 +00:00
Chris Lattner
47dd7a4cf4 rename SIL internals for AllocVar and DeallocVar to [De]AllocStack.
No syntax change yet.


Swift SVN r6382
2013-07-19 19:38:29 +00:00
Anna Zaks
74bc6f05b2 Add "noreturn" attribute : stage 1
- Add the attribute to AnyFunctionType::ExtInfo.
- Propagate the attributes from DeclAttributes to AnyFunctionType for
  FuncDecls in TypeCheckDecl.cpp.
- Make sure the new attribute is serialized.

The main missing pieces are checking the applicability of the type attributes
on the FuncDecl and teaching typechecker about conversions on types with
noreturn.

Swift SVN r6359
2013-07-18 22:57:22 +00:00
Anna Zaks
92e07c6a54 Use ExtInfo struct to pass around call related info in FunctionType and PolymorphicFunctionType getters.
Swift SVN r6358
2013-07-18 22:57:21 +00:00
Manman Ren
457f27ccac SIL Parser: parse archetype_metatype, associated_metatype, class_metatype and
protocol_metatype.

Print type to enable parsing.


Swift SVN r6350
2013-07-18 18:49:04 +00:00
Manman Ren
9023d15dcf SIL Parser: parse global_addr.
The testing case has a global variable defined in .sil: "var x: Int = 0".
When parsing the .sil file, there was an assertion failure where the type of
ValueDecl for x is null. To fix the problem, we set DelayCheckingPattern to
false for SIL in visitPatternBindingDecl.


Swift SVN r6348
2013-07-18 17:44:39 +00:00
Manman Ren
76c9a84586 SIL Parser: parse index_addr and index_raw_pointer.
Swift SVN r6339
2013-07-17 22:21:08 +00:00
Manman Ren
b8262ea1d3 SIL Parser: parse string_literal and float_literal.
Swift SVN r6338
2013-07-17 22:14:01 +00:00
Manman Ren
406ca18e16 SIL Parser: parse is_nonnull.
Add helper function lookupBoolType to find the return type for is_nonnull.


Swift SVN r6336
2013-07-17 21:21:29 +00:00
Argyrios Kyrtzidis
015c1a892b Refactor Parser methods to return TypeReprs directly, instead of modifying TypeLocs.
Swift SVN r6328
2013-07-17 14:57:40 +00:00
Argyrios Kyrtzidis
f616eeee8b Utilize TypeReprs for type checking.
-Refactor Parser to stop creating types
-Refactor TypeChecker to create types by resolving TypeReprs.
-Remove "validation" bit from the type system.
  We don't need to "validate" every type that gets created but there's still a validation bit in TypeLoc,
  necessary because of generic substitutions.

Swift SVN r6326
2013-07-17 14:57:35 +00:00
Manman Ren
ee8e504b79 SIL Parser: parse ref_element_addr.
Print type to enable parsing.


Swift SVN r6316
2013-07-17 01:06:28 +00:00
Manman Ren
04c146855f SIL Parser: parse tuple_element_addr and tuple_extract.
Print type to enable parsing.


Swift SVN r6312
2013-07-17 00:31:42 +00:00
Manman Ren
36dd7bfa84 SIL Parser: parse builtin_zero, struct, struct_element_addr, and struct_extract.
Print type for struct_extract and struct_element_addr to enable parsing.


Swift SVN r6308
2013-07-16 23:23:20 +00:00
Manman Ren
b9444e587c SIL Parser: parse initialize_var.
Swift SVN r6294
2013-07-16 20:30:10 +00:00
Manman Ren
0a19b8e4e3 SIL Parser: parse project_existential_ref.
Swift SVN r6293
2013-07-16 20:19:59 +00:00
Manman Ren
1d507f2e42 SIL Parser: parse copy_addr and upcast_existential.
Modify SILPrinter to print necessary types for parsing.
Format of copy_addr is changed from
  copy_addr Src [take]? to Dst [initialization]?
  to
  copy_addr [take]? Src to [initialization]? Dst : DstType
to put the attribute in front of the actual value.
It also makes parsing easier since '[' can start an array type.


Swift SVN r6268
2013-07-15 19:06:32 +00:00
Chris Lattner
12872e5190 remove the allocation kind enum from alloc_var/dealloc_var/alloc_ref. There is
only one kind now: stack.  alloc_var is just for stack memory now.


Swift SVN r6256
2013-07-15 16:48:56 +00:00
Chris Lattner
5322275156 remove the 'heap' form of alloc_var. It is not used, and the imagined
possible use cases are far enough away that we shouldn't worry about them
now.


Swift SVN r6253
2013-07-15 16:33:09 +00:00
Chris Lattner
5c1320042c remove the "pseudo" class of alloc_var. It is not used.
Swift SVN r6252
2013-07-15 16:25:19 +00:00
Manman Ren
e3ee2f79b2 SILParser: parse an optional volatile attribute for DynamicMethodInst.
Swift SVN r6232
2013-07-13 00:24:58 +00:00
Manman Ren
61d547a2a1 SIL Parser: handle SIL functions with generic params and parse archetype_method.
Construct ArchetypeType from generic params; Construct a Scope for the SIL
function body so TypeAliasDecl for the generic params can be added to ScopeInfo.
Remove an extra '$' in SILPrinter when printing the lookup type for an
archetype_method.


Swift SVN r6219
2013-07-12 22:21:14 +00:00
Manman Ren
80ffd6e693 Parse generic parameters in SIL function definition.
sil_type: '$' '*'? attribute-list (generic-params)? type
Refactor parseTypeAnnotation to separate applyAttributeToType which can be
used from SILParser.


Swift SVN r6209
2013-07-12 19:44:04 +00:00
Doug Gregor
4de26b0a3f Fix newly-introduced NL_Default.
Swift SVN r6074
2013-07-08 22:41:53 +00:00
Dmitri Hrybenko
1c0233efb1 Move lib/Parse/{Parser.h, Scope.h} -> include/swift/Parse/
Swift SVN r6062
2013-07-08 20:36:40 +00:00
Manman Ren
20e85d48a3 SIL Parser: parse class_method.
Swift SVN r6058
2013-07-08 18:50:22 +00:00
Manman Ren
a63c78b81a SIL Parser: parse protocol_method.
New format for SILConstant:
  '#' sil-dotted-path sil-constant-kind-and-uncurry-level?
  sil-dotted-path:
    identifier ('.' identifier)*
  sil-constant-kind-and-uncurry-level:
    '!' sil-constant-kind ('.' sil-constant-uncurry-level)? ('.objc')?
    '!' sil-constant-uncurry-level ('.objc')?
    '!objc'
  sil-constant-kind:
    'func' | 'getter' | 'setter' | 'allocator' | 'initializer' | 'oneofelt' \
    | 'destroyer' | 'globalaccessor'

Add helper function printFullContext in SILPrinter to generate the fully
qualified dotted path for a given DeclContext; Add parseSILConstant to
SILParser; Testing cases are updated to reflect the new format.


Swift SVN r6055
2013-07-08 18:24:15 +00:00
Chris Lattner
39e93652fd Implement support for parsing operands that reference alloc_box
results (and other instructions that produce multiple results).

This includes support for forward references.


Swift SVN r6048
2013-07-08 16:15:15 +00:00
Chris Lattner
dd605118bb use parseValueName to simplify code.
Swift SVN r6047
2013-07-08 15:24:26 +00:00
Chris Lattner
df9ae62700 parse the alloc_box instruction.
Swift SVN r6045
2013-07-08 15:05:06 +00:00
Chris Lattner
dc702b2be5 implement sil parser support for the rest of the unchecked conversion instructions.
Swift SVN r5942
2013-07-01 18:50:37 +00:00
Chris Lattner
4a8a00c91d add parsing support for the rest of the checked conversions. No testcases, poo poo.
Swift SVN r5933
2013-07-01 17:36:06 +00:00
Chris Lattner
e51b88ce95 add silparser support for checked cast instructions, with downcast as an exemplar.
Swift SVN r5930
2013-07-01 17:24:32 +00:00
Chris Lattner
41591909d8 Change the syntax of SIL cast instructions to use the 'to' keyword.
This is better for uniformity with store and also is less of a punctuation
soup, making things easier to read.


Swift SVN r5928
2013-07-01 16:51:02 +00:00