[llvm-commits] [llvm] r53163 [2/7] - in /llvm/branches/non-call-eh: ./ autoconf/ bindings/ocaml/llvm/ docs/ docs/CommandGuide/ docs/tutorial/ examples/BrainF/ examples/Fibonacci/ examples/HowToUseJIT/ examples/ModuleMaker/ examples/ParallelJIT/ include/llvm-c/ include/llvm/ include/llvm/ADT/ include/llvm/Analysis/ include/llvm/Bitcode/ include/llvm/CodeGen/ include/llvm/Debugger/ include/llvm/ExecutionEngine/ include/llvm/Support/ include/llvm/System/ include/llvm/Target/ include/llvm/Transforms/ include/llvm/Transform...

Nick Lewycky nicholas at mxc.ca
Sun Jul 6 13:45:51 PDT 2008


Modified: llvm/branches/non-call-eh/include/llvm/IntrinsicsX86.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/IntrinsicsX86.td?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/IntrinsicsX86.td (original)
+++ llvm/branches/non-call-eh/include/llvm/IntrinsicsX86.td Sun Jul  6 15:45:41 2008
@@ -19,13 +19,13 @@
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse_add_ss : GCCBuiltin<"__builtin_ia32_addss">,
               Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty,
-                         llvm_v4f32_ty], [IntrNoMem]>;
+                         llvm_v4f32_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse_sub_ss : GCCBuiltin<"__builtin_ia32_subss">,
               Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty,
                          llvm_v4f32_ty], [IntrNoMem]>;
   def int_x86_sse_mul_ss : GCCBuiltin<"__builtin_ia32_mulss">,
               Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty,
-                         llvm_v4f32_ty], [IntrNoMem]>;
+                         llvm_v4f32_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse_div_ss : GCCBuiltin<"__builtin_ia32_divss">,
               Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty,
                          llvm_v4f32_ty], [IntrNoMem]>;
@@ -176,13 +176,13 @@
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse2_add_sd : GCCBuiltin<"__builtin_ia32_addsd">,
               Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_v2f64_ty], [IntrNoMem]>;
+                         llvm_v2f64_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_sub_sd : GCCBuiltin<"__builtin_ia32_subsd">,
               Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
                          llvm_v2f64_ty], [IntrNoMem]>;
   def int_x86_sse2_mul_sd : GCCBuiltin<"__builtin_ia32_mulsd">,
               Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_v2f64_ty], [IntrNoMem]>;
+                         llvm_v2f64_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_div_sd : GCCBuiltin<"__builtin_ia32_divsd">,
               Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
                          llvm_v2f64_ty], [IntrNoMem]>;
@@ -256,16 +256,16 @@
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb128">,
               Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty,
-                         llvm_v16i8_ty], [IntrNoMem]>;
+                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb128">,
               Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty,
-                         llvm_v16i8_ty], [IntrNoMem]>;
+                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb128">,
               Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty,
                          llvm_v16i8_ty], [IntrNoMem]>;
@@ -280,37 +280,37 @@
                          llvm_v8i16_ty], [IntrNoMem]>;
   def int_x86_sse2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq128">,
               Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty,
-                         llvm_v4i32_ty], [IntrNoMem]>;
+                         llvm_v4i32_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd128">,
               Intrinsic<[llvm_v4i32_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb128">,
               Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty,
-                         llvm_v16i8_ty], [IntrNoMem]>;
+                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub128">,
               Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty,
-                         llvm_v16i8_ty], [IntrNoMem]>;
+                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub128">,
               Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty,
-                         llvm_v16i8_ty], [IntrNoMem]>;
+                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_sse2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw128">,
               Intrinsic<[llvm_v2i64_ty, llvm_v16i8_ty,
-                         llvm_v16i8_ty], [IntrNoMem]>;
+                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
 }
 
 // Integer shift ops.
@@ -324,9 +324,6 @@
   def int_x86_sse2_psll_q : GCCBuiltin<"__builtin_ia32_psllq128">,
               Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
                          llvm_v2i64_ty], [IntrNoMem]>;
-  def int_x86_sse2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
-                         llvm_i32_ty], [IntrNoMem]>;
   def int_x86_sse2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
                          llvm_v8i16_ty], [IntrNoMem]>;
@@ -336,15 +333,44 @@
   def int_x86_sse2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq128">,
               Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
                          llvm_v2i64_ty], [IntrNoMem]>;
-  def int_x86_sse2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
-                         llvm_i32_ty], [IntrNoMem]>;
   def int_x86_sse2_psra_w : GCCBuiltin<"__builtin_ia32_psraw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
                          llvm_v8i16_ty], [IntrNoMem]>;
   def int_x86_sse2_psra_d : GCCBuiltin<"__builtin_ia32_psrad128">,
               Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty,
                          llvm_v4i32_ty], [IntrNoMem]>;
+
+  def int_x86_sse2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi128">,
+              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi128">,
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi128">,
+              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi128">,
+              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi128">,
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi128">,
+              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi128">,
+              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi128">,
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+
+  def int_x86_sse2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi128">,
+              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_sse2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi128">,
+              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
 }
 
 // Integer comparison ops
@@ -475,35 +501,6 @@
               Intrinsic<[llvm_void_ty], [IntrWriteMem]>;
 }
 
-// Shuffles.
-// FIXME: Temporary workarounds since 2-wide shuffle is broken.
-let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
-  def int_x86_sse2_movs_d : GCCBuiltin<"__builtin_ia32_movsd">,
-              Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_v2f64_ty], [IntrNoMem]>;
-  def int_x86_sse2_loadh_pd : GCCBuiltin<"__builtin_ia32_loadhpd">,
-              Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_ptr_ty], [IntrReadMem]>;
-  def int_x86_sse2_loadl_pd : GCCBuiltin<"__builtin_ia32_loadlpd">,
-              Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_ptr_ty], [IntrReadMem]>;
-  def int_x86_sse2_shuf_pd : GCCBuiltin<"__builtin_ia32_shufpd">,
-              Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_v2f64_ty, llvm_i32_ty], [IntrNoMem]>;
-  def int_x86_sse2_unpckh_pd : GCCBuiltin<"__builtin_ia32_unpckhpd">,
-              Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_v2f64_ty], [IntrNoMem]>;
-  def int_x86_sse2_unpckl_pd : GCCBuiltin<"__builtin_ia32_unpcklpd">,
-              Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
-                         llvm_v2f64_ty], [IntrNoMem]>;
-  def int_x86_sse2_punpckh_qdq : GCCBuiltin<"__builtin_ia32_punpckhqdq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
-                         llvm_v2i64_ty], [IntrNoMem]>;
-  def int_x86_sse2_punpckl_qdq : GCCBuiltin<"__builtin_ia32_punpcklqdq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty,
-                         llvm_v2i64_ty], [IntrNoMem]>;
-}
-
 //===----------------------------------------------------------------------===//
 // SSE3
 
@@ -602,13 +599,16 @@
   def int_x86_ssse3_pmadd_ub_sw_128 : GCCBuiltin<"__builtin_ia32_pmaddubsw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
                          llvm_v8i16_ty], [IntrNoMem]>;
+}
 
+// Packed multiply high with round and scale
+let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_ssse3_pmul_hr_sw      : GCCBuiltin<"__builtin_ia32_pmulhrsw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_ssse3_pmul_hr_sw_128  : GCCBuiltin<"__builtin_ia32_pmulhrsw128">,
               Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty,
-                         llvm_v8i16_ty], [IntrNoMem]>;
+                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
 }
 
 // Shuffle ops
@@ -695,128 +695,170 @@
 // Vector sign and zero extend
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_pmovsxbd        : GCCBuiltin<"__builtin_ia32_pmovsxbd128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v16i8_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovsxbq        : GCCBuiltin<"__builtin_ia32_pmovsxbq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v16i8_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovsxbw        : GCCBuiltin<"__builtin_ia32_pmovsxbw128">,
-              Intrinsic<[llvm_v8i16_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v8i16_ty, llvm_v16i8_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovsxdq        : GCCBuiltin<"__builtin_ia32_pmovsxdq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovsxwd        : GCCBuiltin<"__builtin_ia32_pmovsxwd128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v8i16_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovsxwq        : GCCBuiltin<"__builtin_ia32_pmovsxwq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v8i16_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovzxbd        : GCCBuiltin<"__builtin_ia32_pmovzxbd128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v16i8_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovzxbq        : GCCBuiltin<"__builtin_ia32_pmovzxbq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v16i8_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovzxbw        : GCCBuiltin<"__builtin_ia32_pmovzxbw128">,
-              Intrinsic<[llvm_v8i16_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v8i16_ty, llvm_v16i8_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovzxdq        : GCCBuiltin<"__builtin_ia32_pmovzxdq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovzxwd        : GCCBuiltin<"__builtin_ia32_pmovzxwd128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v8i16_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pmovzxwq        : GCCBuiltin<"__builtin_ia32_pmovzxwq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v8i16_ty],
+                        [IntrNoMem]>;
 }
 
 // Vector min element
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_phminposuw     : GCCBuiltin<"__builtin_ia32_phminposuw128">,
-              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty],
+                        [IntrNoMem]>;
 }
 
 // Vector compare, min, max
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_pcmpeqq         : GCCBuiltin<"__builtin_ia32_pcmpeqq">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pmaxsb          : GCCBuiltin<"__builtin_ia32_pmaxsb128">,
-              Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pmaxsd          : GCCBuiltin<"__builtin_ia32_pmaxsd128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pmaxud          : GCCBuiltin<"__builtin_ia32_pmaxud128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pmaxuw          : GCCBuiltin<"__builtin_ia32_pmaxuw128">,
-              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pminsb          : GCCBuiltin<"__builtin_ia32_pminsb128">,
-              Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty]>;
+              Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pminsd          : GCCBuiltin<"__builtin_ia32_pminsd128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pminud          : GCCBuiltin<"__builtin_ia32_pminud128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pminuw          : GCCBuiltin<"__builtin_ia32_pminuw128">,
-              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty]>;
+              Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty],
+                        [IntrNoMem, Commutative]>;
 }
 
 // Vector pack
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_packusdw        : GCCBuiltin<"__builtin_ia32_packusdw128">,
-              Intrinsic<[llvm_v8i16_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v8i16_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem]>;
 }
 
 // Vector multiply
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_pmuldq          : GCCBuiltin<"__builtin_ia32_pmuldq128">,
-              Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem, Commutative]>;
   def int_x86_sse41_pmulld          : GCCBuiltin<"__builtin_ia32_pmulld128">,
-              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty]>;
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [IntrNoMem, Commutative]>;
 }
 
 // Vector extract
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_pextrb         :
-              Intrinsic<[llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty]>;
+              Intrinsic<[llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pextrd         :
-              Intrinsic<[llvm_i32_ty, llvm_v4i32_ty, llvm_i32_ty]>;
+              Intrinsic<[llvm_i32_ty, llvm_v4i32_ty, llvm_i32_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_pextrq         :
-              Intrinsic<[llvm_i64_ty, llvm_v2i64_ty, llvm_i32_ty]>;
+              Intrinsic<[llvm_i64_ty, llvm_v2i64_ty, llvm_i32_ty],
+                        [IntrNoMem]>;
   def int_x86_sse41_extractps      : GCCBuiltin<"__builtin_ia32_extractps128">,
-              Intrinsic<[llvm_i32_ty, llvm_v4f32_ty, llvm_i32_ty]>;
+              Intrinsic<[llvm_i32_ty, llvm_v4f32_ty, llvm_i32_ty],
+                        [IntrNoMem]>;
 }
 
 // Vector insert
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_pinsrb         : GCCBuiltin<"__builtin_ia32_vec_set_v16qi">,
-          Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty, llvm_i32_ty],
+                    [IntrNoMem]>;
   def int_x86_sse41_pinsrd         : GCCBuiltin<"__builtin_ia32_vec_set_v4si">,
-          Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty],
+                    [IntrNoMem]>;
   def int_x86_sse41_pinsrq         : GCCBuiltin<"__builtin_ia32_vec_set_v2di">,
-          Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, llvm_i64_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, llvm_i64_ty, llvm_i32_ty],
+                    [IntrNoMem]>;
   def int_x86_sse41_insertps       : GCCBuiltin<"__builtin_ia32_insertps128">,
-          Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
+                    [IntrNoMem]>;
 }
 
 // Vector blend
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_pblendvb         : GCCBuiltin<"__builtin_ia32_pblendvb128">,
-        Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty]>;
+        Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
+                  [IntrNoMem]>;
   def int_x86_sse41_pblendw          : GCCBuiltin<"__builtin_ia32_pblendw128">,
-        Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty]>;
+        Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty],
+                  [IntrNoMem]>;
   def int_x86_sse41_blendpd          : GCCBuiltin<"__builtin_ia32_blendpd">,
-        Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty]>;
+        Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty],
+                  [IntrNoMem]>;
   def int_x86_sse41_blendps          : GCCBuiltin<"__builtin_ia32_blendps">,
-        Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty]>;
+        Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
+                  [IntrNoMem]>;
   def int_x86_sse41_blendvpd         : GCCBuiltin<"__builtin_ia32_blendvpd">,
-        Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty]>;
+        Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
+                  [IntrNoMem]>;
   def int_x86_sse41_blendvps         : GCCBuiltin<"__builtin_ia32_blendvps">,
-        Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty]>;
+        Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
+                  [IntrNoMem]>;
 }
 
 // Vector dot product
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_dppd            : GCCBuiltin<"__builtin_ia32_dppd">,
-          Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty],
+                    [IntrNoMem, Commutative]>;
   def int_x86_sse41_dpps            : GCCBuiltin<"__builtin_ia32_dpps">,
-          Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
+                    [IntrNoMem, Commutative]>;
 }
 
 // Vector sum of absolute differences
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_mpsadbw         : GCCBuiltin<"__builtin_ia32_mpsadbw128">,
-          Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty]>;
+          Intrinsic<[llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty],
+                    [IntrNoMem, Commutative]>;
 }
 
-// Vector sum of absolute differences
+// Cacheability support ops
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_sse41_movntdqa        : GCCBuiltin<"__builtin_ia32_movntdqa">,
           Intrinsic<[llvm_v2i64_ty, llvm_ptr_ty], [IntrReadMem]>;
@@ -839,17 +881,17 @@
   // Addition
   def int_x86_mmx_padds_b : GCCBuiltin<"__builtin_ia32_paddsb">,
               Intrinsic<[llvm_v8i8_ty, llvm_v8i8_ty,
-                         llvm_v8i8_ty], [IntrNoMem]>;
+                         llvm_v8i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_padds_w : GCCBuiltin<"__builtin_ia32_paddsw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
 
   def int_x86_mmx_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb">,
               Intrinsic<[llvm_v8i8_ty, llvm_v8i8_ty,
-                         llvm_v8i8_ty], [IntrNoMem]>;
+                         llvm_v8i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
 
   // Subtraction
   def int_x86_mmx_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb">,
@@ -869,45 +911,45 @@
   // Multiplication
   def int_x86_mmx_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq">,
               Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty,
-                         llvm_v2i32_ty], [IntrNoMem]>;
+                         llvm_v2i32_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd">,
               Intrinsic<[llvm_v2i32_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
 
   // Averages
   def int_x86_mmx_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb">,
               Intrinsic<[llvm_v8i8_ty, llvm_v8i8_ty,
-                         llvm_v8i8_ty], [IntrNoMem]>;
+                         llvm_v8i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
 
   // Maximum
   def int_x86_mmx_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub">,
               Intrinsic<[llvm_v8i8_ty, llvm_v8i8_ty,
-                         llvm_v8i8_ty], [IntrNoMem]>;
+                         llvm_v8i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
 
   // Minimum
   def int_x86_mmx_pminu_b : GCCBuiltin<"__builtin_ia32_pminub">,
               Intrinsic<[llvm_v8i8_ty, llvm_v8i8_ty,
-                         llvm_v8i8_ty], [IntrNoMem]>;
+                         llvm_v8i8_ty], [IntrNoMem, Commutative]>;
   def int_x86_mmx_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
-                         llvm_v4i16_ty], [IntrNoMem]>;
+                         llvm_v4i16_ty], [IntrNoMem, Commutative]>;
 
   // Packed sum of absolute differences
   def int_x86_mmx_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw">,
               Intrinsic<[llvm_v4i16_ty, llvm_v8i8_ty,
-                         llvm_v8i8_ty], [IntrNoMem]>;
+                         llvm_v8i8_ty], [IntrNoMem, Commutative]>;
 }
 
 // Integer shift ops.
@@ -939,6 +981,33 @@
   def int_x86_mmx_psra_d : GCCBuiltin<"__builtin_ia32_psrad">,
               Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty,
                          llvm_v1i64_ty], [IntrNoMem]>;
+
+  def int_x86_mmx_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi">,
+              Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_mmx_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi">,
+              Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_mmx_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi">,
+              Intrinsic<[llvm_v1i64_ty, llvm_v1i64_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+
+  def int_x86_mmx_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi">,
+              Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_mmx_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi">,
+              Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_mmx_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi">,
+              Intrinsic<[llvm_v1i64_ty,   llvm_v1i64_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+
+  def int_x86_mmx_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi">,
+              Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
+  def int_x86_mmx_psrai_d : GCCBuiltin<"__builtin_ia32_psradi">,
+              Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty,
+                         llvm_i32_ty], [IntrNoMem]>;
 }
 
 // Pack ops.

Modified: llvm/branches/non-call-eh/include/llvm/LinkAllPasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/LinkAllPasses.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/LinkAllPasses.h (original)
+++ llvm/branches/non-call-eh/include/llvm/LinkAllPasses.h Sun Jul  6 15:45:41 2008
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/FindUsedTypes.h"
 #include "llvm/Analysis/IntervalPartition.h"
 #include "llvm/Analysis/LoadValueNumbering.h"
+#include "llvm/Analysis/LoopVR.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
@@ -48,6 +49,7 @@
       (void) llvm::createArgumentPromotionPass();
       (void) llvm::createStructRetPromotionPass();
       (void) llvm::createBasicAliasAnalysisPass();
+      (void) llvm::createLibCallAliasAnalysisPass(0);
       (void) llvm::createBasicVNPass();
       (void) llvm::createBlockPlacementPass();
       (void) llvm::createBlockProfilerPass();
@@ -114,10 +116,14 @@
       (void) llvm::createCodeGenPreparePass();
       (void) llvm::createGVNPass();
       (void) llvm::createMemCpyOptPass();
+      (void) llvm::createLoopDeletionPass();
+      (void) llvm::createPostDomTree();
+      (void) llvm::createPostDomFrontier();
 
       (void)new llvm::IntervalPartition();
       (void)new llvm::FindUsedTypes();
       (void)new llvm::ScalarEvolution();
+      (void)new llvm::LoopVR();
       ((llvm::Function*)0)->viewCFGOnly();
       llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)0);
       X.add((llvm::Value*)0, 0);  // for -print-alias-sets

Removed: llvm/branches/non-call-eh/include/llvm/LinkTimeOptimizer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/LinkTimeOptimizer.h?rev=53162&view=auto

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/LinkTimeOptimizer.h (original)
+++ llvm/branches/non-call-eh/include/llvm/LinkTimeOptimizer.h (removed)
@@ -1,178 +0,0 @@
-//===-- llvm/LinkTimeOptimizer.h - Public Interface  ------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-// 
-//===----------------------------------------------------------------------===//
-//
-// This header provides public interface to use LLVM link time optimization
-// library. This is intended to be used by linker to do link time optimization.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __LTO_H__
-#define __LTO_H__
-
-#include <string>
-#include <vector>
-#include <set>
-#include <llvm/ADT/hash_map>
-#include <cstring>
-
-#define LLVM_LTO_VERSION 2
-
-namespace llvm {
-
-  class Module;
-  class GlobalValue;
-  class TargetMachine;
-
-  enum LTOStatus {
-    LTO_UNKNOWN,
-    LTO_OPT_SUCCESS,
-    LTO_READ_SUCCESS,
-    LTO_READ_FAILURE,
-    LTO_WRITE_FAILURE,
-    LTO_NO_TARGET,
-    LTO_NO_WORK,
-    LTO_MODULE_MERGE_FAILURE,
-    LTO_ASM_FAILURE
-  };
- 
-  enum LTOLinkageTypes {
-    LTOExternalLinkage, // Externally visible function
-    LTOLinkOnceLinkage, // Keep one copy of named function when linking (inline)
-    LTOWeakLinkage,     // Keep one copy of named function when linking (weak)
-    LTOInternalLinkage  // Rename collisions when linking (static functions)
-  };
-
-  enum LTOVisibilityTypes {
-    LTODefaultVisibility = 0,  ///< The GV is visible
-    LTOHiddenVisibility,       ///< The GV is hidden
-    LTOProtectedVisibility     ///< The GV is protected
-  };
-
-
-  enum LTOCodeGenModel {
-    LTO_CGM_Static,
-    LTO_CGM_Dynamic,
-    LTO_CGM_DynamicNoPIC
-  };
-
-  /// This class represents LLVM symbol information without exposing details
-  /// of LLVM global values. It encapsulates symbol linkage information. This
-  /// is typically used in hash_map where associated name identifies the 
-  /// the symbol name.
-  class LLVMSymbol {
-
-  public:
-
-    LTOLinkageTypes getLinkage() const { return linkage; }
-    LTOVisibilityTypes getVisibility() const { return visibility; }
-    void mayBeNotUsed();
-
-    LLVMSymbol (enum LTOLinkageTypes lt, enum LTOVisibilityTypes vis, 
-                GlobalValue *g, const std::string &n, 
-                const std::string &m, int a) : linkage(lt), visibility(vis),
-                                               gv(g), name(n), 
-                                               mangledName(m), alignment(a) {}
-
-    const char *getName() { return name.c_str(); }
-    const char *getMangledName() { return mangledName.c_str(); }
-    int getAlignment() { return alignment; }
-
-  private:
-    enum LTOLinkageTypes linkage;
-    enum LTOVisibilityTypes visibility;
-    GlobalValue *gv;
-    std::string name;
-    std::string mangledName;
-    int alignment;
-  };
-
-  class string_compare {
-  public:
-    bool operator()(const char* left, const char* right) const { 
-      return (strcmp(left, right) == 0); 
-    }
-  };
-
-  /// This is abstract class to facilitate dlopen() interface.
-  /// See LTO below for more info.
-  class LinkTimeOptimizer {
-  public:
-    typedef hash_map<const char*, LLVMSymbol*, hash<const char*>, 
-                     string_compare> NameToSymbolMap;
-    typedef hash_map<const char*, Module*, hash<const char*>, 
-                     string_compare> NameToModuleMap;
-    virtual enum LTOStatus readLLVMObjectFile(const std::string &,
-                                              NameToSymbolMap &,
-                                              std::set<std::string> &) = 0;
-    virtual enum LTOStatus optimizeModules(const std::string &,
-                                           std::vector<const char*> &exportList,
-                                           std::string &targetTriple,
-                                           bool saveTemps, const char *) = 0;
-    virtual void getTargetTriple(const std::string &, std::string &) = 0;
-    virtual void removeModule (const std::string &InputFilename) = 0;
-    virtual void setCodeGenModel(LTOCodeGenModel CGM) = 0;
-    virtual void printVersion () = 0;
-    virtual ~LinkTimeOptimizer() = 0;
-  };
-
-  /// This is the main link time optimization class. It exposes simple API
-  /// to perform link time optimization using LLVM intermodular optimizer.
-  class LTO : public LinkTimeOptimizer {
-
-  public:
-    typedef hash_map<const char*, LLVMSymbol*, hash<const char*>, 
-                     string_compare> NameToSymbolMap;
-    typedef hash_map<const char*, Module*, hash<const char*>, 
-                     string_compare> NameToModuleMap;
-
-    enum LTOStatus readLLVMObjectFile(const std::string &InputFilename,
-                                      NameToSymbolMap &symbols,
-                                      std::set<std::string> &references);
-    enum LTOStatus optimizeModules(const std::string &OutputFilename,
-                                   std::vector<const char*> &exportList,
-                                   std::string &targetTriple, 
-                                   bool saveTemps,  const char *);
-    void getTargetTriple(const std::string &InputFilename, 
-                         std::string &targetTriple);
-    void removeModule (const std::string &InputFilename);
-    void printVersion();
-
-    void setCodeGenModel(LTOCodeGenModel CGM) {
-      CGModel = CGM;
-    }
-
-    // Constructors and destructors
-    LTO() : Target(NULL), CGModel(LTO_CGM_Dynamic) {
-      /// TODO: Use Target info, it is available at this time.
-    }
-    ~LTO();
-
-  private:
-    Module *getModule (const std::string &InputFilename);
-    enum LTOStatus optimize(Module *, std::ostream &, 
-                            std::vector<const char *> &);
-    void getTarget(Module *);
-
-  private:
-    std::vector<Module *> modules;
-    NameToSymbolMap allSymbols;
-    NameToModuleMap allModules;
-    TargetMachine *Target;
-    LTOCodeGenModel CGModel;
-  };
-
-} // End llvm namespace
-
-/// This provides C interface to initialize link time optimizer. This allows
-/// linker to use dlopen() interface to dynamically load LinkTimeOptimizer.
-/// extern "C" helps, because dlopen() interface uses name to find the symbol.
-extern "C"
-llvm::LinkTimeOptimizer *createLLVMOptimizer(unsigned VERSION = LLVM_LTO_VERSION);
-
-#endif

Modified: llvm/branches/non-call-eh/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Module.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Module.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Module.h Sun Jul  6 15:45:41 2008
@@ -209,6 +209,7 @@
   /// getFunction - Look up the specified function in the module symbol table.
   /// If it does not exist, return null.
   Function *getFunction(const std::string &Name) const;
+  Function *getFunction(const char *Name) const;
 
 /// @}
 /// @name Global Variable Accessors

Modified: llvm/branches/non-call-eh/include/llvm/ModuleProvider.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/ModuleProvider.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/ModuleProvider.h (original)
+++ llvm/branches/non-call-eh/include/llvm/ModuleProvider.h Sun Jul  6 15:45:41 2008
@@ -48,7 +48,7 @@
   /// it up to be materialized lazily.  If the provider doesn't support this
   /// capability, this method is a noop.
   ///
-  virtual void dematerializeFunction(Function *F) {}
+  virtual void dematerializeFunction(Function *) {}
   
   /// materializeModule - make sure the entire Module has been completely read.
   /// On error, return null and fill in the error string if specified.
@@ -77,10 +77,10 @@
   explicit ExistingModuleProvider(Module *M) {
     TheModule = M;
   }
-  bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
+  bool materializeFunction(Function *, std::string * = 0) {
     return false;
   }
-  Module* materializeModule(std::string *ErrInfo = 0) { return TheModule; }
+  Module* materializeModule(std::string * = 0) { return TheModule; }
 };
 
 } // End llvm namespace

Added: llvm/branches/non-call-eh/include/llvm/OperandTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/OperandTraits.h?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/OperandTraits.h (added)
+++ llvm/branches/non-call-eh/include/llvm/OperandTraits.h Sun Jul  6 15:45:41 2008
@@ -0,0 +1,181 @@
+//===-- llvm/OperandTraits.h - OperandTraits class definition ---------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the traits classes that are handy for enforcing the correct
+// layout of various User subclasses. It also provides the means for accessing
+// the operands in the most efficient manner.
+//
+
+#ifndef LLVM_OPERAND_TRAITS_H
+#define LLVM_OPERAND_TRAITS_H
+
+#include "llvm/User.h"
+
+namespace llvm {
+
+//===----------------------------------------------------------------------===//
+//                          FixedNumOperands Trait Class
+//===----------------------------------------------------------------------===//
+
+/// FixedNumOperandTraits - determine the allocation regime of the Use array
+/// when it is a prefix to the User object, and the number of Use objects is
+/// known at compile time.
+
+template <unsigned ARITY>
+struct FixedNumOperandTraits {
+  static Use *op_begin(User* U) {
+    return reinterpret_cast<Use*>(U) - ARITY;
+  }
+  static Use *op_end(User* U) {
+    return reinterpret_cast<Use*>(U);
+  }
+  static unsigned operands(const User*) {
+    return ARITY;
+  }
+  struct prefix {
+    Use Ops[ARITY];
+    prefix(); // DO NOT IMPLEMENT
+  };
+  template <class U>
+  struct Layout {
+    struct overlay : prefix, U {
+      overlay(); // DO NOT IMPLEMENT
+    };
+  };
+  static inline void *allocate(unsigned); // FIXME
+};
+
+//===----------------------------------------------------------------------===//
+//                          OptionalOperands Trait Class
+//===----------------------------------------------------------------------===//
+
+template <unsigned ARITY = 1>
+struct OptionalOperandTraits : FixedNumOperandTraits<ARITY> {
+  static unsigned operands(const User *U) {
+    return U->getNumOperands();
+  }
+};
+
+//===----------------------------------------------------------------------===//
+//                          VariadicOperand Trait Class
+//===----------------------------------------------------------------------===//
+
+/// VariadicOperandTraits - determine the allocation regime of the Use array
+/// when it is a prefix to the User object, and the number of Use objects is
+/// only known at allocation time.
+
+template <unsigned MINARITY = 0>
+struct VariadicOperandTraits {
+  static Use *op_begin(User* U) {
+    return reinterpret_cast<Use*>(U) - U->getNumOperands();
+  }
+  static Use *op_end(User* U) {
+    return reinterpret_cast<Use*>(U);
+  }
+  static unsigned operands(const User *U) {
+    return U->getNumOperands();
+  }
+  static inline void *allocate(unsigned); // FIXME
+};
+
+//===----------------------------------------------------------------------===//
+//                          HungoffOperand Trait Class
+//===----------------------------------------------------------------------===//
+
+/// HungoffOperandTraits - determine the allocation regime of the Use array
+/// when it is not a prefix to the User object, but allocated at an unrelated
+/// heap address.
+/// Assumes that the User subclass that is determined by this traits class
+/// has an OperandList member of type User::op_iterator. [Note: this is now
+/// trivially satisfied, because User has that member for historic reasons.]
+///
+/// This is the traits class that is needed when the Use array must be
+/// resizable.
+
+template <unsigned MINARITY = 1>
+struct HungoffOperandTraits {
+  static Use *op_begin(User* U) {
+    return U->OperandList;
+  }
+  static Use *op_end(User* U) {
+    return U->OperandList + U->getNumOperands();
+  }
+  static unsigned operands(const User *U) {
+    return U->getNumOperands();
+  }
+  static inline void *allocate(unsigned); // FIXME
+};
+
+/// Macro for generating in-class operand accessor declarations.
+/// It should only be called in the public section of the interface.
+///
+#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \
+  public: \
+  inline VALUECLASS *getOperand(unsigned) const; \
+  inline void setOperand(unsigned, VALUECLASS*); \
+  protected: \
+  template <unsigned> inline Use &Op(); \
+  template <unsigned> inline const Use &Op() const; \
+  public: \
+  inline unsigned getNumOperands() const
+
+/// Macro for generating out-of-class operand accessor definitions
+#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \
+VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
+  assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
+         && "getOperand() out of range!"); \
+  return static_cast<VALUECLASS*>( \
+    OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture]); \
+} \
+void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
+  assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
+         && "setOperand() out of range!"); \
+  OperandTraits<CLASS>::op_begin(this)[i_nocapture] = Val_nocapture; \
+} \
+unsigned CLASS::getNumOperands() const { \
+  return OperandTraits<CLASS>::operands(this);  \
+} \
+template <unsigned Idx_nocapture> Use &CLASS::Op() { \
+  return OperandTraits<CLASS>::op_begin(this)[Idx_nocapture]; \
+} \
+template <unsigned Idx_nocapture> const Use &CLASS::Op() const { \
+  return OperandTraits<CLASS>::op_begin( \
+    const_cast<CLASS*>(this))[Idx_nocapture]; \
+}
+
+
+/// Macro for generating out-of-class operand accessor
+/// definitions with casted result
+#define DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(CLASS, VALUECLASS) \
+VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
+  assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
+         && "getOperand() out of range!"); \
+  return cast<VALUECLASS>( \
+    OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture]); \
+} \
+void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
+  assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
+         && "setOperand() out of range!"); \
+  OperandTraits<CLASS>::op_begin(this)[i_nocapture] = Val_nocapture; \
+} \
+unsigned CLASS::getNumOperands() const { \
+  return OperandTraits<CLASS>::operands(this); \
+} \
+template <unsigned Idx_nocapture> Use &CLASS::Op() { \
+  return OperandTraits<CLASS>::op_begin(this)[Idx_nocapture]; \
+} \
+template <unsigned Idx_nocapture> const Use &CLASS::Op() const { \
+  return OperandTraits<CLASS>::op_begin( \
+    const_cast<CLASS*>(this))[Idx_nocapture]; \
+}
+
+
+} // End llvm namespace
+
+#endif

Modified: llvm/branches/non-call-eh/include/llvm/ParameterAttributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/ParameterAttributes.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/ParameterAttributes.h (original)
+++ llvm/branches/non-call-eh/include/llvm/ParameterAttributes.h Sun Jul  6 15:45:41 2008
@@ -68,7 +68,7 @@
 
 /// This turns an int alignment (a power of 2, normally) into the
 /// form used internally in ParameterAttributes.
-ParamAttr::Attributes inline constructAlignmentFromInt(unsigned i) {
+inline ParamAttr::Attributes constructAlignmentFromInt(unsigned i) {
   return (i << 16);
 }
 
@@ -124,7 +124,7 @@
   template <typename Iter>
   static PAListPtr get(const Iter &I, const Iter &E) {
     if (I == E) return PAListPtr();  // Empty list.
-    return get(&*I, E-I);
+    return get(&*I, static_cast<unsigned>(E-I));
   }
 
   /// addAttr - Add the specified attribute at the specified index to this

Modified: llvm/branches/non-call-eh/include/llvm/Pass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Pass.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Pass.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Pass.h Sun Jul  6 15:45:41 2008
@@ -82,8 +82,7 @@
   Pass(const Pass &);           // DO NOT IMPLEMENT
 public:
   explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {}
-  explicit Pass(const void *pid) : Resolver(0), 
-                                                    PassID((intptr_t)pid) {}
+  explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {}
   virtual ~Pass();
 
   /// getPassName - Return a nice clean name for a pass.  This usually
@@ -110,10 +109,10 @@
 
   /// Each pass is responsible for assigning a pass manager to itself.
   /// PMS is the stack of available pass manager. 
-  virtual void assignPassManager(PMStack &PMS, 
-                                 PassManagerType T = PMT_Unknown) {}
+  virtual void assignPassManager(PMStack &, 
+                                 PassManagerType = PMT_Unknown) {}
   /// Check if available pass managers are suitable for this pass or not.
-  virtual void preparePassManager(PMStack &PMS) {}
+  virtual void preparePassManager(PMStack &) {}
   
   ///  Return what kind of Pass Manager can manage this pass.
   virtual PassManagerType getPotentialPassManagerType() const {
@@ -126,7 +125,6 @@
     Resolver = AR; 
   }
   inline AnalysisResolver *getResolver() { 
-    assert (Resolver && "Resolver is not set");
     return Resolver; 
   }
 
@@ -135,7 +133,7 @@
   /// particular analysis result to this function, it can then use the
   /// getAnalysis<AnalysisType>() function, below.
   ///
-  virtual void getAnalysisUsage(AnalysisUsage &Info) const {
+  virtual void getAnalysisUsage(AnalysisUsage &) const {
     // By default, no analysis results are used, all are invalidated.
   }
 
@@ -251,7 +249,7 @@
 
   /// ImmutablePasses are never run.
   ///
-  bool runOnModule(Module &M) { return false; }
+  bool runOnModule(Module &) { return false; }
 
   explicit ImmutablePass(intptr_t pid) : ModulePass(pid) {}
   explicit ImmutablePass(const void *pid) 
@@ -278,7 +276,7 @@
   /// doInitialization - Virtual method overridden by subclasses to do
   /// any necessary per-module initialization.
   ///
-  virtual bool doInitialization(Module &M) { return false; }
+  virtual bool doInitialization(Module &) { return false; }
 
   /// runOnFunction - Virtual method overriden by subclasses to do the
   /// per-function processing of the pass.
@@ -288,7 +286,7 @@
   /// doFinalization - Virtual method overriden by subclasses to do any post
   /// processing needed after all passes have run.
   ///
-  virtual bool doFinalization(Module &M) { return false; }
+  virtual bool doFinalization(Module &) { return false; }
 
   /// runOnModule - On a module, we run this pass by initializing,
   /// ronOnFunction'ing once for every function in the module, then by
@@ -330,12 +328,12 @@
   /// doInitialization - Virtual method overridden by subclasses to do
   /// any necessary per-module initialization.
   ///
-  virtual bool doInitialization(Module &M) { return false; }
+  virtual bool doInitialization(Module &) { return false; }
 
   /// doInitialization - Virtual method overridden by BasicBlockPass subclasses
   /// to do any necessary per-function initialization.
   ///
-  virtual bool doInitialization(Function &F) { return false; }
+  virtual bool doInitialization(Function &) { return false; }
 
   /// runOnBasicBlock - Virtual method overriden by subclasses to do the
   /// per-basicblock processing of the pass.
@@ -345,12 +343,12 @@
   /// doFinalization - Virtual method overriden by BasicBlockPass subclasses to
   /// do any post processing needed after all passes have run.
   ///
-  virtual bool doFinalization(Function &F) { return false; }
+  virtual bool doFinalization(Function &) { return false; }
 
   /// doFinalization - Virtual method overriden by subclasses to do any post
   /// processing needed after all passes have run.
   ///
-  virtual bool doFinalization(Module &M) { return false; }
+  virtual bool doFinalization(Module &) { return false; }
 
 
   // To run this pass on a function, we simply call runOnBasicBlock once for

Modified: llvm/branches/non-call-eh/include/llvm/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/PassManager.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/PassManager.h (original)
+++ llvm/branches/non-call-eh/include/llvm/PassManager.h Sun Jul  6 15:45:41 2008
@@ -95,6 +95,12 @@
   /// doFinalization - Run all of the finalizers for the function passes.
   ///
   bool doFinalization();
+  
+  /// getModuleProvider - Return the module provider that this passmanager is
+  /// currently using.  This is the module provider that it uses when a function
+  /// is optimized that is non-resident in the module.
+  ModuleProvider *getModuleProvider() const { return MP; }
+  void setModuleProvider(ModuleProvider *NewMP) { MP = NewMP; }
 
 private:
   FunctionPassManagerImpl *FPM;

Modified: llvm/branches/non-call-eh/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/PassManagers.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/PassManagers.h (original)
+++ llvm/branches/non-call-eh/include/llvm/PassManagers.h Sun Jul  6 15:45:41 2008
@@ -86,6 +86,9 @@
 #ifndef PASSMANAGERS_H
 #define PASSMANAGERS_H
 
+#include "llvm/Pass.h"
+#include <deque>
+
 namespace llvm {
 
 /// FunctionPassManager and PassManager, two top level managers, serve 
@@ -145,8 +148,8 @@
 class PMTopLevelManager {
 public:
 
-  virtual unsigned getNumContainedManagers() {
-    return PassManagers.size();
+  virtual unsigned getNumContainedManagers() const {
+    return (unsigned)PassManagers.size();
   }
 
   /// Schedule pass P for execution. Make sure that passes required by
@@ -242,6 +245,9 @@
   /// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
   void verifyPreservedAnalysis(Pass *P);
 
+  /// verifyDomInfo -- Verify dominator information if it is available.
+  void verifyDomInfo(Pass &P, Function &F);
+
   /// Remove Analysis that is not preserved by the pass
   void removeNotPreservedAnalysis(Pass *P);
   
@@ -305,8 +311,8 @@
   void dumpAnalysisSetInfo(const char *Msg, Pass *P,
                            const std::vector<AnalysisID> &Set) const;
 
-  virtual unsigned getNumContainedPasses() { 
-    return PassVector.size();
+  virtual unsigned getNumContainedPasses() const {
+    return (unsigned)PassVector.size();
   }
 
   virtual PassManagerType getPassManagerType() const { 

Modified: llvm/branches/non-call-eh/include/llvm/PassSupport.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/PassSupport.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/PassSupport.h (original)
+++ llvm/branches/non-call-eh/include/llvm/PassSupport.h Sun Jul  6 15:45:41 2008
@@ -21,7 +21,6 @@
 #ifndef LLVM_PASS_SUPPORT_H
 #define LLVM_PASS_SUPPORT_H
 
-#include "llvm/System/IncludeFile.h"
 // No need to include Pass.h, we are being included by it!
 
 namespace llvm {
@@ -35,30 +34,43 @@
 /// template, defined below.
 ///
 class PassInfo {
-  const char           *PassName;      // Nice name for Pass
-  const char           *PassArgument;  // Command Line argument to run this pass
-  intptr_t             PassID;      
-  bool IsCFGOnlyPass;                  // Pass only looks at the CFG.
-  bool IsAnalysis;                     // True if an analysis pass.
-  bool IsAnalysisGroup;                // True if an analysis group.
+public:
+  typedef Pass* (*NormalCtor_t)();
+
+private:
+  const char      *const PassName;     // Nice name for Pass
+  const char      *const PassArgument; // Command Line argument to run this pass
+  const intptr_t  PassID;      
+  const bool IsCFGOnlyPass;            // Pass only looks at the CFG.
+  const bool IsAnalysis;               // True if an analysis pass.
+  const bool IsAnalysisGroup;          // True if an analysis group.
   std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
 
-  Pass *(*NormalCtor)();
+  NormalCtor_t NormalCtor;
 
 public:
   /// PassInfo ctor - Do not call this directly, this should only be invoked
   /// through RegisterPass.
   PassInfo(const char *name, const char *arg, intptr_t pi,
-           Pass *(*normal)() = 0, bool isCFGOnly = false, bool isAnalysis = false)
+           NormalCtor_t normal = 0,
+           bool isCFGOnly = false, bool is_analysis = false)
     : PassName(name), PassArgument(arg), PassID(pi), 
       IsCFGOnlyPass(isCFGOnly), 
-      IsAnalysis(isAnalysis), IsAnalysisGroup(false), NormalCtor(normal) {
+      IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal) {
+    registerPass();
+  }
+  /// PassInfo ctor - Do not call this directly, this should only be invoked
+  /// through RegisterPass. This version is for use by analysis groups; it
+  /// does not auto-register the pass.
+  PassInfo(const char *name, intptr_t pi)
+    : PassName(name), PassArgument(""), PassID(pi), 
+      IsCFGOnlyPass(false), 
+      IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0) {
   }
 
   /// getPassName - Return the friendly name for the pass, never returns null
   ///
   const char *getPassName() const { return PassName; }
-  void setPassName(const char *Name) { PassName = Name; }
 
   /// getPassArgument - Return the command line option that may be passed to
   /// 'opt' that will cause this pass to be run.  This will return null if there
@@ -75,7 +87,6 @@
   ///
   bool isAnalysisGroup() const { return IsAnalysisGroup; }
   bool isAnalysis() const { return IsAnalysis; }
-  void SetIsAnalysisGroup() { IsAnalysisGroup = true; }
 
   /// isCFGOnlyPass - return true if this pass only looks at the CFG for the
   /// function.
@@ -85,10 +96,10 @@
   /// an instance of the pass and returns it.  This pointer may be null if there
   /// is no default constructor for the pass.
   ///
-  Pass *(*getNormalCtor() const)() {
+  NormalCtor_t getNormalCtor() const {
     return NormalCtor;
   }
-  void setNormalCtor(Pass *(*Ctor)()) {
+  void setNormalCtor(NormalCtor_t Ctor) {
     NormalCtor = Ctor;
   }
 
@@ -115,9 +126,27 @@
   const std::vector<const PassInfo*> &getInterfacesImplemented() const {
     return ItfImpl;
   }
+
+  /// getPassInfo - Deprecated API compaatibility function. This function
+  /// just returns 'this'.
+  ///
+  const PassInfo *getPassInfo() const {
+    return this;
+  }
+
+protected:
+  void registerPass();
+  void unregisterPass();
+
+private:
+  void operator=(const PassInfo &); // do not implement
+  PassInfo(const PassInfo &);       // do not implement
 };
 
 
+template<typename PassName>
+Pass *callDefaultCtor() { return new PassName(); }
+
 //===---------------------------------------------------------------------------
 /// RegisterPass<t> template - This template class is used to notify the system
 /// that a Pass is available for use, and registers it into the internal
@@ -135,44 +164,15 @@
 ///
 /// static RegisterPass<PassClassName> tmp("passopt", "My Name");
 ///
-struct RegisterPassBase {
-  /// getPassInfo - Get the pass info for the registered class...
-  ///
-  const PassInfo *getPassInfo() const { return &PIObj; }
-
-  typedef Pass* (*NormalCtor_t)();
-  
-  RegisterPassBase(const char *Name, const char *Arg, intptr_t TI,
-                   NormalCtor_t NormalCtor = 0, bool CFGOnly = false, 
-                   bool IsAnalysis = false)
-    : PIObj(Name, Arg, TI, NormalCtor, CFGOnly, IsAnalysis) {
-    registerPass();
-  }
-  explicit RegisterPassBase(intptr_t TI)
-    : PIObj("", "", TI) {
-    // This ctor may only be used for analysis groups: it does not auto-register
-    // the pass.
-    PIObj.SetIsAnalysisGroup();
-  }
-
-protected:
-  PassInfo PIObj;       // The PassInfo object for this pass
-  void registerPass();
-  void unregisterPass();
-};
-
-template<typename PassName>
-Pass *callDefaultCtor() { return new PassName(); }
-
-template<typename PassName>
-struct RegisterPass : public RegisterPassBase {
+template<typename passName>
+struct RegisterPass : public PassInfo {
 
   // Register Pass using default constructor...
   RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false,
-               bool IsAnalysis = false)
-    : RegisterPassBase(Name, PassArg, intptr_t(&PassName::ID),
-                      RegisterPassBase::NormalCtor_t(callDefaultCtor<PassName>),
-                      CFGOnly, IsAnalysis) {
+               bool is_analysis = false)
+    : PassInfo(Name, PassArg, intptr_t(&passName::ID),
+               PassInfo::NormalCtor_t(callDefaultCtor<passName>),
+               CFGOnly, is_analysis) {
   }
 };
 
@@ -185,7 +185,7 @@
 ///
 /// If no analysis implementing the interface is available, a default
 /// implementation is created and added.  A pass registers itself as the default
-/// implementation by specifying 'true' as the third template argument of this
+/// implementation by specifying 'true' as the second template argument of this
 /// class.
 ///
 /// In addition to registering itself as an analysis group member, a pass must
@@ -196,27 +196,27 @@
 /// second template argument).  The interface should be registered to associate
 /// a nice name with the interface.
 ///
-class RegisterAGBase : public RegisterPassBase {
+class RegisterAGBase : public PassInfo {
   PassInfo *InterfaceInfo;
   const PassInfo *ImplementationInfo;
   bool isDefaultImplementation;
 protected:
-  explicit RegisterAGBase(intptr_t InterfaceID,
+  explicit RegisterAGBase(const char *Name,
+                          intptr_t InterfaceID,
                           intptr_t PassID = 0,
                           bool isDefault = false);
-  void setGroupName(const char *Name);
 };
 
 template<typename Interface, bool Default = false>
 struct RegisterAnalysisGroup : public RegisterAGBase {
-  explicit RegisterAnalysisGroup(RegisterPassBase &RPB)
-    : RegisterAGBase(intptr_t(&Interface::ID), RPB.getPassInfo()->getTypeInfo(),
+  explicit RegisterAnalysisGroup(PassInfo &RPB)
+    : RegisterAGBase(RPB.getPassName(),
+                     intptr_t(&Interface::ID), RPB.getTypeInfo(),
                      Default) {
   }
 
   explicit RegisterAnalysisGroup(const char *Name)
-    : RegisterAGBase(intptr_t(&Interface::ID)) {
-    setGroupName(Name);
+    : RegisterAGBase(Name, intptr_t(&Interface::ID)) {
   }
 };
 
@@ -244,7 +244,7 @@
   /// Callback functions - These functions are invoked whenever a pass is loaded
   /// or removed from the current executable.
   ///
-  virtual void passRegistered(const PassInfo *P) {}
+  virtual void passRegistered(const PassInfo *) {}
 
   /// enumeratePasses - Iterate over the registered passes, calling the
   /// passEnumerate callback on each PassInfo object.
@@ -254,7 +254,7 @@
   /// passEnumerate - Callback function invoked when someone calls
   /// enumeratePasses on this PassRegistrationListener object.
   ///
-  virtual void passEnumerate(const PassInfo *P) {}
+  virtual void passEnumerate(const PassInfo *) {}
 };
 
 

Modified: llvm/branches/non-call-eh/include/llvm/Support/AlignOf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/AlignOf.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/AlignOf.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/AlignOf.h Sun Jul  6 15:45:41 2008
@@ -34,11 +34,19 @@
 ///  compile-time constant (e.g., for template instantiation).
 template <typename T>
 struct AlignOf {
-  enum { Alignment = sizeof(AlignmentCalcImpl<T>) - sizeof(T) };
+  enum { Alignment =
+         static_cast<unsigned int>(sizeof(AlignmentCalcImpl<T>) - sizeof(T)) };
+
   enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
   enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
   enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 };
   enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 };
+  
+  enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 };
+  enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 }; 
+  enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 };
+  enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 };
+
 };
 
 /// alignof - A templated function that returns the mininum alignment of

Modified: llvm/branches/non-call-eh/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/Allocator.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/Allocator.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/Allocator.h Sun Jul  6 15:45:41 2008
@@ -25,12 +25,14 @@
   ~MallocAllocator() {}
   
   void Reset() {}
-  void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
+
+  void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); }
   
   template <typename T>
-  void *Allocate() { return reinterpret_cast<T*>(malloc(sizeof(T))); }
+  T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); }
   
   void Deallocate(void *Ptr) { free(Ptr); }
+
   void PrintStats() const {}
 };
 
@@ -45,15 +47,16 @@
   ~BumpPtrAllocator();
   
   void Reset();
-  void *Allocate(unsigned Size, unsigned Alignment);
+
+  void *Allocate(size_t Size, size_t Alignment);
 
   template <typename T>
-  void *Allocate() { 
-    return reinterpret_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
+  T *Allocate() { 
+    return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
   }
-
   
-  void Deallocate(void *Ptr) {}
+  void Deallocate(void */*Ptr*/) {}
+
   void PrintStats() const;
 };
 

Modified: llvm/branches/non-call-eh/include/llvm/Support/CFG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/CFG.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/CFG.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/CFG.h Sun Jul  6 15:45:41 2008
@@ -18,7 +18,7 @@
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/Function.h"
 #include "llvm/InstrTypes.h"
-#include "llvm/ADT/iterator"
+#include "llvm/ADT/iterator.h"
 
 namespace llvm {
 
@@ -34,17 +34,14 @@
   typedef PredIterator<_Ptr,_USE_iterator> _Self;
   typedef typename super::pointer pointer;
 
-  inline void advancePastNonPreds() {
-    // Loop to ignore non predecessor uses (for example PHI nodes)...
-    while (!It.atEnd()) {
-      if (isa<TerminatorInst>(*It) || isa<BasicBlock>(*It))
-	break;
+  inline void advancePastNonTerminators() {
+    // Loop to ignore non terminator uses (for example PHI nodes)...
+    while (!It.atEnd() && !isa<TerminatorInst>(*It))
       ++It;
-    }
   }
 
   inline PredIterator(_Ptr *bb) : It(bb->use_begin()) {
-    advancePastNonPreds();
+    advancePastNonTerminators();
   }
   inline PredIterator(_Ptr *bb, bool) : It(bb->use_end()) {}
 
@@ -60,16 +57,13 @@
 
   inline pointer operator*() const {
     assert(!It.atEnd() && "pred_iterator out of range!");
-    if (isa<TerminatorInst>(*It))      // not dyn_cast due to const-correctness
-      return cast<TerminatorInst>(*It)->getParent();
-
-    return cast<_Ptr>(*It);
+    return cast<TerminatorInst>(*It)->getParent();
   }
   inline pointer *operator->() const { return &(operator*()); }
 
   inline _Self& operator++() {   // Preincrement
     assert(!It.atEnd() && "pred_iterator out of range!");
-    ++It; advancePastNonPreds();
+    ++It; advancePastNonTerminators();
     return *this;
   }
 
@@ -113,8 +107,6 @@
   inline SuccIterator(Term_ T, bool)                       // end iterator
     : Term(T), idx(Term->getNumSuccessors()) {
     assert(T && "getTerminator returned null!");
-    if (Term->getParent()->getUnwindDest())
-      ++idx;
   }
 
   inline const _Self &operator=(const _Self &I) {

Modified: llvm/branches/non-call-eh/include/llvm/Support/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/CallSite.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/CallSite.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/CallSite.h Sun Jul  6 15:45:41 2008
@@ -129,6 +129,10 @@
     else
       I->setOperand(ArgNo+3, newVal); // Skip Function, BB, BB
   }
+  
+  /// hasArgument - Returns true if this CallSite passes the given Value* as an
+  /// argument to the called function.
+  bool hasArgument(const Value *Arg) const;
 
   /// arg_iterator - The type of iterator to use when looping over actual
   /// arguments at this call site...

Modified: llvm/branches/non-call-eh/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/CommandLine.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/CommandLine.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/CommandLine.h Sun Jul  6 15:45:41 2008
@@ -41,14 +41,16 @@
 // ParseCommandLineOptions - Command line option processing entry point.
 //
 void ParseCommandLineOptions(int argc, char **argv,
-                             const char *Overview = 0);
+                             const char *Overview = 0,
+                             bool ReadResponseFiles = false);
 
 //===----------------------------------------------------------------------===//
 // ParseEnvironmentOptions - Environment variable option processing alternate
 //                           entry point.
 //
 void ParseEnvironmentOptions(const char *progName, const char *envvar,
-                             const char *Overview = 0);
+                             const char *Overview = 0,
+                             bool ReadResponseFiles = false);
 
 ///===---------------------------------------------------------------------===//
 /// SetVersionPrinter - Override the default (LLVM specific) version printer
@@ -146,10 +148,10 @@
   virtual enum ValueExpected getValueExpectedFlagDefault() const {
     return ValueOptional;
   }
-  
+
   // Out of line virtual function to provide home for the class.
   virtual void anchor();
-  
+
   int NumOccurrences;     // The number of times specified
   int Flags;              // Flags for the argument
   unsigned Position;      // Position of last occurrence of the option
@@ -213,19 +215,19 @@
   // addArgument - Register this argument with the commandline system.
   //
   void addArgument();
-  
+
   Option *getNextRegisteredOption() const { return NextRegistered; }
 
   // Return the width of the option tag for printing...
-  virtual unsigned getOptionWidth() const = 0;
+  virtual size_t getOptionWidth() const = 0;
 
   // printOptionInfo - Print out information about this option.  The
   // to-be-maintained width is specified.
   //
-  virtual void printOptionInfo(unsigned GlobalWidth) const = 0;
+  virtual void printOptionInfo(size_t GlobalWidth) const = 0;
+
+  virtual void getExtraOptionNames(std::vector<const char*> &) {}
 
-  virtual void getExtraOptionNames(std::vector<const char*> &OptionNames) {}
-  
   // addOccurrence - Wrapper around handleOccurrence that enforces Flags
   //
   bool addOccurrence(unsigned pos, const char *ArgName,
@@ -322,24 +324,25 @@
     Values.push_back(std::make_pair(EnumName, std::make_pair(Val, Desc)));
 
     // Process the varargs portion of the values...
-    while (const char *EnumName = va_arg(ValueArgs, const char *)) {
+    while (const char *enumName = va_arg(ValueArgs, const char *)) {
       DataType EnumVal = static_cast<DataType>(va_arg(ValueArgs, int));
       const char *EnumDesc = va_arg(ValueArgs, const char *);
-      Values.push_back(std::make_pair(EnumName,      // Add value to value map
+      Values.push_back(std::make_pair(enumName,      // Add value to value map
                                       std::make_pair(EnumVal, EnumDesc)));
     }
   }
 
   template<class Opt>
   void apply(Opt &O) const {
-    for (unsigned i = 0, e = Values.size(); i != e; ++i)
+    for (unsigned i = 0, e = static_cast<unsigned>(Values.size());
+         i != e; ++i)
       O.getParser().addLiteralOption(Values[i].first, Values[i].second.first,
                                      Values[i].second.second);
   }
 };
 
 template<class DataType>
-ValuesClass<DataType> END_WITH_NULL values(const char *Arg, DataType Val, 
+ValuesClass<DataType> END_WITH_NULL values(const char *Arg, DataType Val,
                                            const char *Desc, ...) {
     va_list ValueArgs;
     va_start(ValueArgs, Desc);
@@ -376,12 +379,12 @@
   virtual const char *getDescription(unsigned N) const = 0;
 
   // Return the width of the option tag for printing...
-  virtual unsigned getOptionWidth(const Option &O) const;
+  virtual size_t getOptionWidth(const Option &O) const;
 
   // printOptionInfo - Print out information about this option.  The
   // to-be-maintained width is specified.
   //
-  virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const;
+  virtual void printOptionInfo(const Option &O, size_t GlobalWidth) const;
 
   void initialize(Option &O) {
     // All of the modifiers for the option have been processed by now, so the
@@ -389,7 +392,7 @@
     //
     hasArgStr = O.hasArgStr();
   }
-  
+
   void getExtraOptionNames(std::vector<const char*> &OptionNames) {
     // If there has been no argstr specified, that means that we need to add an
     // argument for every possible option.  This ensures that our options are
@@ -457,7 +460,8 @@
     else
       ArgVal = ArgName;
 
-    for (unsigned i = 0, e = Values.size(); i != e; ++i)
+    for (unsigned i = 0, e = static_cast<unsigned>(Values.size());
+         i != e; ++i)
       if (ArgVal == Values[i].first) {
         V = Values[i].second.first;
         return false;
@@ -495,17 +499,17 @@
     return ValueRequired;
   }
 
-  void getExtraOptionNames(std::vector<const char*> &OptionNames) {}
+  void getExtraOptionNames(std::vector<const char*> &) {}
 
-  void initialize(Option &O) {}
+  void initialize(Option &) {}
 
   // Return the width of the option tag for printing...
-  unsigned getOptionWidth(const Option &O) const;
+  size_t getOptionWidth(const Option &O) const;
 
   // printOptionInfo - Print out information about this option.  The
   // to-be-maintained width is specified.
   //
-  void printOptionInfo(const Option &O, unsigned GlobalWidth) const;
+  void printOptionInfo(const Option &O, size_t GlobalWidth) const;
 
   // getValueName - Overload in subclass to provide a better default value.
   virtual const char *getValueName() const { return "value"; }
@@ -537,7 +541,7 @@
 
   // getValueName - Do not print =<value> at all.
   virtual const char *getValueName() const { return 0; }
-  
+
   // An out-of-line virtual method to provide a 'home' for this class.
   virtual void anchor();
 };
@@ -551,7 +555,7 @@
 class parser<boolOrDefault> : public basic_parser<boolOrDefault> {
 public:
   // parse - Return true on error.
-  bool parse(Option &O, const char *ArgName, const std::string &Arg, 
+  bool parse(Option &O, const char *ArgName, const std::string &Arg,
              boolOrDefault &Val);
 
   enum ValueExpected getValueExpectedFlagDefault() const {
@@ -560,7 +564,7 @@
 
   // getValueName - Do not print =<value> at all.
   virtual const char *getValueName() const { return 0; }
-  
+
   // An out-of-line virtual method to provide a 'home' for this class.
   virtual void anchor();
 };
@@ -647,7 +651,7 @@
 class parser<std::string> : public basic_parser<std::string> {
 public:
   // parse - Return true on error.
-  bool parse(Option &O, const char *AN, const std::string &Arg,
+  bool parse(Option &, const char *, const std::string &Arg,
              std::string &Value) {
     Value = Arg;
     return false;
@@ -813,8 +817,8 @@
   }
 
   // Forward printing stuff to the parser...
-  virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
-  virtual void printOptionInfo(unsigned GlobalWidth) const {
+  virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
+  virtual void printOptionInfo(size_t GlobalWidth) const {
     Parser.printOptionInfo(*this, GlobalWidth);
   }
 
@@ -965,7 +969,7 @@
   virtual void getExtraOptionNames(std::vector<const char*> &OptionNames) {
     return Parser.getExtraOptionNames(OptionNames);
   }
-  
+
   virtual bool handleOccurrence(unsigned pos, const char *ArgName,
                                 const std::string &Arg) {
     typename ParserClass::parser_data_type Val =
@@ -979,8 +983,8 @@
   }
 
   // Forward printing stuff to the parser...
-  virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
-  virtual void printOptionInfo(unsigned GlobalWidth) const {
+  virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
+  virtual void printOptionInfo(size_t GlobalWidth) const {
     Parser.printOptionInfo(*this, GlobalWidth);
   }
 
@@ -1071,7 +1075,7 @@
 template<class DataType, class StorageClass>
 class bits_storage {
   unsigned *Location;   // Where to store the bits...
-  
+
   template<class T>
   static unsigned Bit(const T &V) {
     unsigned BitPos = reinterpret_cast<unsigned>(V);
@@ -1096,9 +1100,9 @@
            "line option with external storage!");
     *Location |= Bit(V);
   }
-  
+
   unsigned getBits() { return *Location; }
-  
+
   template<class T>
   bool isSet(const T &V) {
     return (*Location & Bit(V)) != 0;
@@ -1106,13 +1110,13 @@
 };
 
 
-// Define how to hold bits.  Since we can inherit from a class, we do so. 
+// Define how to hold bits.  Since we can inherit from a class, we do so.
 // This makes us exactly compatible with the bits in all cases that it is used.
 //
 template<class DataType>
 class bits_storage<DataType, bool> {
   unsigned Bits;   // Where to store the bits...
-  
+
   template<class T>
   static unsigned Bit(const T &V) {
     unsigned BitPos = reinterpret_cast<unsigned>(V);
@@ -1120,15 +1124,15 @@
           "enum exceeds width of bit vector!");
     return 1 << BitPos;
   }
-  
+
 public:
   template<class T>
   void addValue(const T &V) {
     Bits |=  Bit(V);
   }
-  
+
   unsigned getBits() { return Bits; }
-  
+
   template<class T>
   bool isSet(const T &V) {
     return (Bits & Bit(V)) != 0;
@@ -1151,7 +1155,7 @@
   virtual void getExtraOptionNames(std::vector<const char*> &OptionNames) {
     return Parser.getExtraOptionNames(OptionNames);
   }
-  
+
   virtual bool handleOccurrence(unsigned pos, const char *ArgName,
                                 const std::string &Arg) {
     typename ParserClass::parser_data_type Val =
@@ -1165,8 +1169,8 @@
   }
 
   // Forward printing stuff to the parser...
-  virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
-  virtual void printOptionInfo(unsigned GlobalWidth) const {
+  virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
+  virtual void printOptionInfo(size_t GlobalWidth) const {
     Parser.printOptionInfo(*this, GlobalWidth);
   }
 
@@ -1253,13 +1257,13 @@
 
 class alias : public Option {
   Option *AliasFor;
-  virtual bool handleOccurrence(unsigned pos, const char *ArgName,
+  virtual bool handleOccurrence(unsigned pos, const char * /*ArgName*/,
                                 const std::string &Arg) {
     return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
   }
   // Handle printing stuff...
-  virtual unsigned getOptionWidth() const;
-  virtual void printOptionInfo(unsigned GlobalWidth) const;
+  virtual size_t getOptionWidth() const;
+  virtual void printOptionInfo(size_t GlobalWidth) const;
 
   void done() {
     if (!hasArgStr())

Modified: llvm/branches/non-call-eh/include/llvm/Support/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/Dwarf.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/Dwarf.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/Dwarf.h Sun Jul  6 15:45:41 2008
@@ -16,8 +16,6 @@
 #ifndef LLVM_SUPPORT_DWARF_H
 #define LLVM_SUPPORT_DWARF_H
 
-#include "llvm/System/IncludeFile.h"
-
 namespace llvm {
 
 namespace dwarf {
@@ -567,6 +565,4 @@
 
 } // End of namespace llvm
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SupportDwarf)
-
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/Support/GraphWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/GraphWriter.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/GraphWriter.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/GraphWriter.h Sun Jul  6 15:45:41 2008
@@ -175,8 +175,8 @@
         child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI);
 
         // Figure out which edge this targets...
-        unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
-                                        TargetIt);
+        unsigned Offset =
+          (unsigned)std::distance(GTraits::child_begin(TargetNode), TargetIt);
         DestPort = static_cast<int>(Offset);
       }
 

Modified: llvm/branches/non-call-eh/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/IRBuilder.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/IRBuilder.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/IRBuilder.h Sun Jul  6 15:45:41 2008
@@ -18,6 +18,8 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/Instructions.h"
 #include "llvm/Constants.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/Function.h"
 
 namespace llvm {
 
@@ -69,16 +71,18 @@
   
   /// Insert - Insert and return the specified instruction.
   template<typename InstTy>
-  InstTy *Insert(InstTy *I) const {
-    InsertHelper(I);
+  InstTy *Insert(InstTy *I, const char *Name = "") const {
+    InsertHelper(I, Name);
     return I;
   }
   
   /// InsertHelper - Insert the specified instruction at the specified insertion
   /// point.  This is split out of Insert so that it isn't duplicated for every
   /// template instantiation.
-  void InsertHelper(Instruction *I) const {
+  void InsertHelper(Instruction *I, const char *Name) const {
     if (BB) BB->getInstList().insert(InsertPt, I);
+    if (Name[0])
+      I->setName(Name);
   }
   
   //===--------------------------------------------------------------------===//
@@ -98,12 +102,12 @@
   }
 
   ReturnInst *CreateRet(Value * const* retVals, unsigned N) {
-    return Insert(ReturnInst::Create(retVals,  N));
+    return Insert(ReturnInst::Create(retVals, N));
   }
   
   GetResultInst *CreateGetResult(Value *V, unsigned Index, 
                                  const char *Name = "") {
-    return Insert(new GetResultInst(V, Index, Name));
+    return Insert(new GetResultInst(V, Index), Name);
   }
     
   /// CreateBr - Create an unconditional 'br label X' instruction.
@@ -130,7 +134,7 @@
                            BasicBlock *UnwindDest, InputIterator ArgBegin, 
                            InputIterator ArgEnd, const char *Name = "") {
     return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
-                                     ArgBegin, ArgEnd, Name));
+                                     ArgBegin, ArgEnd), Name);
   }
   
   UnwindInst *CreateUnwind() {
@@ -149,103 +153,103 @@
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getAdd(LC, RC);      
-    return Insert(BinaryOperator::createAdd(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateAdd(LHS, RHS), Name);
   }
   Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getSub(LC, RC);
-    return Insert(BinaryOperator::createSub(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateSub(LHS, RHS), Name);
   }
   Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getMul(LC, RC);
-    return Insert(BinaryOperator::createMul(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateMul(LHS, RHS), Name);
   }
   Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getUDiv(LC, RC);
-    return Insert(BinaryOperator::createUDiv(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
   }
   Value *CreateSDiv(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getSDiv(LC, RC);      
-    return Insert(BinaryOperator::createSDiv(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
   }
   Value *CreateFDiv(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getFDiv(LC, RC);      
-    return Insert(BinaryOperator::createFDiv(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateFDiv(LHS, RHS), Name);
   }
   Value *CreateURem(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getURem(LC, RC);
-    return Insert(BinaryOperator::createURem(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
   }
   Value *CreateSRem(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getSRem(LC, RC);
-    return Insert(BinaryOperator::createSRem(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
   }
   Value *CreateFRem(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getFRem(LC, RC);
-    return Insert(BinaryOperator::createFRem(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateFRem(LHS, RHS), Name);
   }
   Value *CreateShl(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getShl(LC, RC);
-    return Insert(BinaryOperator::createShl(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateShl(LHS, RHS), Name);
   }
   Value *CreateLShr(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getLShr(LC, RC);
-    return Insert(BinaryOperator::createLShr(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
   }
   Value *CreateAShr(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getAShr(LC, RC);
-    return Insert(BinaryOperator::createAShr(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
   }
   Value *CreateAnd(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getAnd(LC, RC);
-    return Insert(BinaryOperator::createAnd(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
   }
   Value *CreateOr(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getOr(LC, RC);
-    return Insert(BinaryOperator::createOr(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
   }
   Value *CreateXor(Value *LHS, Value *RHS, const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getXor(LC, RC);
-    return Insert(BinaryOperator::createXor(LHS, RHS, Name));
+    return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
   }
 
   BinaryOperator *CreateBinOp(Instruction::BinaryOps Opc,
                               Value *LHS, Value *RHS, const char *Name = "") {
-    return Insert(BinaryOperator::create(Opc, LHS, RHS, Name));
+    return Insert(BinaryOperator::Create(Opc, LHS, RHS), Name);
   }
   
   BinaryOperator *CreateNeg(Value *V, const char *Name = "") {
-    return Insert(BinaryOperator::createNeg(V, Name));
+    return Insert(BinaryOperator::CreateNeg(V), Name);
   }
   BinaryOperator *CreateNot(Value *V, const char *Name = "") {
-    return Insert(BinaryOperator::createNot(V, Name));
+    return Insert(BinaryOperator::CreateNot(V), Name);
   }
   
   //===--------------------------------------------------------------------===//
@@ -254,11 +258,11 @@
   
   MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0,
                            const char *Name = "") {
-    return Insert(new MallocInst(Ty, ArraySize, Name));
+    return Insert(new MallocInst(Ty, ArraySize), Name);
   }
   AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0,
                            const char *Name = "") {
-    return Insert(new AllocaInst(Ty, ArraySize, Name));
+    return Insert(new AllocaInst(Ty, ArraySize), Name);
   }
   FreeInst *CreateFree(Value *Ptr) {
     return Insert(new FreeInst(Ptr));
@@ -284,15 +288,16 @@
           break;
       }
       if (i == IdxEnd)
-        return ConstantExpr::getGetElementPtr(PC, &IdxBegin[0], IdxEnd - IdxBegin);
+        return ConstantExpr::getGetElementPtr(PC, &IdxBegin[0], 
+                                              IdxEnd - IdxBegin);
     }      
-    return(Insert(GetElementPtrInst::Create(Ptr, IdxBegin, IdxEnd, Name)));
+    return(Insert(GetElementPtrInst::Create(Ptr, IdxBegin, IdxEnd), Name));
   }
   Value *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") {
     if (Constant *PC = dyn_cast<Constant>(Ptr))
       if (Constant *IC = dyn_cast<Constant>(Idx))
         return ConstantExpr::getGetElementPtr(PC, &IC, 1);
-    return Insert(GetElementPtrInst::Create(Ptr, Idx, Name));
+    return Insert(GetElementPtrInst::Create(Ptr, Idx), Name);
   }
   Value *CreateStructGEP(Value *Ptr, unsigned Idx, const char *Name = "") {
     llvm::Value *Idxs[] = {
@@ -303,9 +308,26 @@
     if (Constant *PC = dyn_cast<Constant>(Ptr))
       return ConstantExpr::getGetElementPtr(PC, Idxs, 2);
     
-    return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2, Name));
+    return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);
+  }
+  Value *CreateGlobalString(const char *Str = "", const char *Name = "") {
+    Constant *StrConstant = ConstantArray::get(Str, true);
+    GlobalVariable *gv = new llvm::GlobalVariable(StrConstant->getType(),
+                                                  true, 
+                                                  GlobalValue::InternalLinkage,
+                                                  StrConstant,
+                                                  "",
+                                                  BB->getParent()->getParent(),
+                                                  false);
+    gv->setName(Name);
+    return gv;
+  }
+  Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") {
+    Value *gv = CreateGlobalString(Str, Name);
+    Value *zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
+    Value *Args[] = { zero, zero };
+    return CreateGEP(gv, Args, Args+2, Name);    
   }
-  
   //===--------------------------------------------------------------------===//
   // Instruction creation methods: Cast/Conversion Operators
   //===--------------------------------------------------------------------===//
@@ -357,7 +379,7 @@
       return V;
     if (Constant *VC = dyn_cast<Constant>(V))
       return ConstantExpr::getCast(Op, VC, DestTy);      
-    return Insert(CastInst::create(Op, V, DestTy, Name));
+    return Insert(CastInst::Create(Op, V, DestTy), Name);
   }
   Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned,
                         const char *Name = "") {
@@ -365,7 +387,7 @@
       return V;
     if (Constant *VC = dyn_cast<Constant>(V))
       return ConstantExpr::getIntegerCast(VC, DestTy, isSigned);
-    return Insert(CastInst::createIntegerCast(V, DestTy, isSigned, Name));
+    return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned), Name);
   }
 
   //===--------------------------------------------------------------------===//
@@ -446,19 +468,34 @@
     return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name);
   }
 
-  Value *CreateICmp(ICmpInst::Predicate P, Value *LHS, Value *RHS, 
+  Value *CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, 
+                    const char *Name = "") {
+    if (Constant *LC = dyn_cast<Constant>(LHS))
+      if (Constant *RC = dyn_cast<Constant>(RHS))
+        return ConstantExpr::getCompare(P, LC, RC);      
+    return Insert(new ICmpInst(P, LHS, RHS), Name);
+  }
+  Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, 
+                    const char *Name = "") {
+    if (Constant *LC = dyn_cast<Constant>(LHS))
+      if (Constant *RC = dyn_cast<Constant>(RHS))
+        return ConstantExpr::getCompare(P, LC, RC);
+    return Insert(new FCmpInst(P, LHS, RHS), Name);
+  }
+
+  Value *CreateVICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, 
                      const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getCompare(P, LC, RC);      
-    return Insert(new ICmpInst(P, LHS, RHS, Name));
+    return Insert(new VICmpInst(P, LHS, RHS), Name);
   }
-  Value *CreateFCmp(FCmpInst::Predicate P, Value *LHS, Value *RHS, 
+  Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, 
                      const char *Name = "") {
     if (Constant *LC = dyn_cast<Constant>(LHS))
       if (Constant *RC = dyn_cast<Constant>(RHS))
         return ConstantExpr::getCompare(P, LC, RC);
-    return Insert(new FCmpInst(P, LHS, RHS, Name));
+    return Insert(new VFCmpInst(P, LHS, RHS), Name);
   }
 
   //===--------------------------------------------------------------------===//
@@ -466,33 +503,48 @@
   //===--------------------------------------------------------------------===//
 
   PHINode *CreatePHI(const Type *Ty, const char *Name = "") {
-    return Insert(PHINode::Create(Ty, Name));
+    return Insert(PHINode::Create(Ty), Name);
   }
 
   CallInst *CreateCall(Value *Callee, const char *Name = "") {
-    return Insert(CallInst::Create(Callee, Name));
+    return Insert(CallInst::Create(Callee), Name);
   }
   CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") {
-    return Insert(CallInst::Create(Callee, Arg, Name));
+    return Insert(CallInst::Create(Callee, Arg), Name);
   }
-
+  CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2,
+                        const char *Name = "") {
+    Value *Args[] = { Arg1, Arg2 };
+    return Insert(CallInst::Create(Callee, Args, Args+2), Name);
+  }
+  CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
+                        const char *Name = "") {
+    Value *Args[] = { Arg1, Arg2, Arg3 };
+    return Insert(CallInst::Create(Callee, Args, Args+3), Name);
+  }
+  CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3,
+                        Value *Arg4, const char *Name = "") {
+    Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
+    return Insert(CallInst::Create(Callee, Args, Args+4), Name);
+  }
+  
   template<typename InputIterator>
   CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, 
-                     InputIterator ArgEnd, const char *Name = "") {
-    return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd, Name));
+                       InputIterator ArgEnd, const char *Name = "") {
+    return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name);
   }
 
   Value *CreateSelect(Value *C, Value *True, Value *False,
-                         const char *Name = "") {
+                      const char *Name = "") {
     if (Constant *CC = dyn_cast<Constant>(C))
       if (Constant *TC = dyn_cast<Constant>(True))
         if (Constant *FC = dyn_cast<Constant>(False))
           return ConstantExpr::getSelect(CC, TC, FC);      
-    return Insert(SelectInst::Create(C, True, False, Name));
+    return Insert(SelectInst::Create(C, True, False), Name);
   }
 
   VAArgInst *CreateVAArg(Value *List, const Type *Ty, const char *Name = "") {
-    return Insert(new VAArgInst(List, Ty, Name));
+    return Insert(new VAArgInst(List, Ty), Name);
   }
 
   Value *CreateExtractElement(Value *Vec, Value *Idx,
@@ -500,7 +552,7 @@
     if (Constant *VC = dyn_cast<Constant>(Vec))
       if (Constant *IC = dyn_cast<Constant>(Idx))
         return ConstantExpr::getExtractElement(VC, IC);
-    return Insert(new ExtractElementInst(Vec, Idx, Name));
+    return Insert(new ExtractElementInst(Vec, Idx), Name);
   }
 
   Value *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx,
@@ -509,7 +561,7 @@
       if (Constant *NC = dyn_cast<Constant>(NewElt))
         if (Constant *IC = dyn_cast<Constant>(Idx))
           return ConstantExpr::getInsertElement(VC, NC, IC);
-    return Insert(InsertElementInst::Create(Vec, NewElt, Idx, Name));
+    return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
   }
 
   Value *CreateShuffleVector(Value *V1, Value *V2, Value *Mask,
@@ -518,7 +570,7 @@
       if (Constant *V2C = dyn_cast<Constant>(V2))
         if (Constant *MC = dyn_cast<Constant>(Mask))
           return ConstantExpr::getShuffleVector(V1C, V2C, MC);      
-    return Insert(new ShuffleVectorInst(V1, V2, Mask, Name));
+    return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
   }
 };
   

Modified: llvm/branches/non-call-eh/include/llvm/Support/InstVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/InstVisitor.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/InstVisitor.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/InstVisitor.h Sun Jul  6 15:45:41 2008
@@ -169,6 +169,8 @@
   RetTy visitUnreachableInst(UnreachableInst &I)    { DELEGATE(TerminatorInst);}
   RetTy visitICmpInst(ICmpInst &I)                  { DELEGATE(CmpInst);}
   RetTy visitFCmpInst(FCmpInst &I)                  { DELEGATE(CmpInst);}
+  RetTy visitVICmpInst(VICmpInst &I)                { DELEGATE(CmpInst);}
+  RetTy visitVFCmpInst(VFCmpInst &I)                { DELEGATE(CmpInst);}
   RetTy visitMallocInst(MallocInst &I)              { DELEGATE(AllocationInst);}
   RetTy visitAllocaInst(AllocaInst &I)              { DELEGATE(AllocationInst);}
   RetTy visitFreeInst(FreeInst     &I)              { DELEGATE(Instruction); }
@@ -195,6 +197,8 @@
   RetTy visitInsertElementInst(InsertElementInst &I) { DELEGATE(Instruction); }
   RetTy visitShuffleVectorInst(ShuffleVectorInst &I) { DELEGATE(Instruction); }
   RetTy visitGetResultInst(GetResultInst &I) { DELEGATE(Instruction); }
+  RetTy visitExtractValueInst(ExtractValueInst &I)  { DELEGATE(Instruction);}
+  RetTy visitInsertValueInst(InsertValueInst &I)    { DELEGATE(Instruction); }
 
   // Next level propagators... if the user does not overload a specific
   // instruction type, they can overload one of these to get the whole class

Modified: llvm/branches/non-call-eh/include/llvm/Support/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/Mangler.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/Mangler.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/Mangler.h Sun Jul  6 15:45:41 2008
@@ -14,7 +14,7 @@
 #ifndef LLVM_SUPPORT_MANGLER_H
 #define LLVM_SUPPORT_MANGLER_H
 
-#include "llvm/System/IncludeFile.h"
+#include "llvm/ADT/DenseMap.h"
 #include <map>
 #include <set>
 #include <string>
@@ -41,7 +41,7 @@
   
   /// Memo - This is used to remember the name that we assign a value.
   ///
-  std::map<const Value*, std::string> Memo;
+  DenseMap<const Value*, std::string> Memo;
 
   /// Count - This simple counter is used to unique value names.
   ///
@@ -112,7 +112,4 @@
 
 } // End llvm namespace
 
-// Force the Mangler.cpp file to be linked when this header is #included
-FORCE_DEFINING_FILE_TO_BE_LINKED(Mangler)
-
 #endif // LLVM_SUPPORT_MANGLER_H

Modified: llvm/branches/non-call-eh/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/MathExtras.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/MathExtras.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/MathExtras.h Sun Jul  6 15:45:41 2008
@@ -396,6 +396,18 @@
   // The largest power of 2 that divides both A and B.
   return (A | B) & -(A | B);
 }
+
+/// NextPowerOf2 - Returns the next power of two (in 64-bits)
+/// that is strictly greater than A.  Returns zero on overflow.
+static inline uint64_t NextPowerOf2(uint64_t A) {
+  A |= (A >> 1);
+  A |= (A >> 2);
+  A |= (A >> 4);
+  A |= (A >> 8);
+  A |= (A >> 16);
+  A |= (A >> 32);
+  return A + 1;
+}
   
 } // End llvm namespace
 

Modified: llvm/branches/non-call-eh/include/llvm/Support/MemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/MemoryBuffer.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/MemoryBuffer.h Sun Jul  6 15:45:41 2008
@@ -40,7 +40,7 @@
   
   const char *getBufferStart() const { return BufferStart; }
   const char *getBufferEnd() const   { return BufferEnd; }
-  unsigned getBufferSize() const { return BufferEnd-BufferStart; }
+  size_t getBufferSize() const { return BufferEnd-BufferStart; }
   
   /// getBufferIdentifier - Return an identifier for this buffer, typically the
   /// filename it was read from.
@@ -71,14 +71,14 @@
   /// is completely initialized to zeros.  Note that the caller should
   /// initialize the memory allocated by this method.  The memory is owned by
   /// the MemoryBuffer object.
-  static MemoryBuffer *getNewMemBuffer(unsigned Size,
+  static MemoryBuffer *getNewMemBuffer(size_t Size,
                                        const char *BufferName = "");
   
   /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size
   /// that is not initialized.  Note that the caller should initialize the
   /// memory allocated by this method.  The memory is owned by the MemoryBuffer
   /// object.
-  static MemoryBuffer *getNewUninitMemBuffer(unsigned Size,
+  static MemoryBuffer *getNewUninitMemBuffer(size_t Size,
                                              const char *BufferName = "");
   
   /// getSTDIN - Read all of stdin into a file buffer, and return it.  This

Modified: llvm/branches/non-call-eh/include/llvm/Support/OutputBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/OutputBuffer.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/OutputBuffer.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/OutputBuffer.h Sun Jul  6 15:45:41 2008
@@ -107,8 +107,10 @@
         outxword(X);
     }
     void outstring(const std::string &S, unsigned Length) {
-      unsigned len_to_copy = S.length() < Length ? S.length() : Length;
-      unsigned len_to_fill = S.length() < Length ? Length - S.length() : 0;
+      unsigned len_to_copy = static_cast<unsigned>(S.length()) < Length
+        ? static_cast<unsigned>(S.length()) : Length;
+      unsigned len_to_fill = static_cast<unsigned>(S.length()) < Length
+        ? Length - static_cast<unsigned>(S.length()) : 0;
       
       for (unsigned i = 0; i < len_to_copy; ++i)
         outbyte(S[i]);

Modified: llvm/branches/non-call-eh/include/llvm/Support/PassNameParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/PassNameParser.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/PassNameParser.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/PassNameParser.h Sun Jul  6 15:45:41 2008
@@ -82,7 +82,7 @@
 
   // printOptionInfo - Print out information about this option.  Override the
   // default implementation to sort the table before we print...
-  virtual void printOptionInfo(const cl::Option &O, unsigned GlobalWidth) const{
+  virtual void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const {
     PassNameParser *PNP = const_cast<PassNameParser*>(this);
     std::sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan);
     cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth);

Modified: llvm/branches/non-call-eh/include/llvm/Support/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/PatternMatch.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/PatternMatch.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/PatternMatch.h Sun Jul  6 15:45:41 2008
@@ -385,6 +385,35 @@
 inline not_match<LHS> m_Not(const LHS &L) { return L; }
 
 
+template<typename LHS_t>
+struct neg_match {
+  LHS_t L;
+  
+  neg_match(const LHS_t &LHS) : L(LHS) {}
+  
+  template<typename OpTy>
+  bool match(OpTy *V) {
+    if (Instruction *I = dyn_cast<Instruction>(V))
+      if (I->getOpcode() == Instruction::Sub)
+        return matchIfNeg(I->getOperand(0), I->getOperand(1));
+    if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
+      if (CE->getOpcode() == Instruction::Sub)
+        return matchIfNeg(CE->getOperand(0), CE->getOperand(1));
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
+      return L.match(ConstantExpr::getNeg(CI));
+    return false;
+  }
+private:
+  bool matchIfNeg(Value *LHS, Value *RHS) {
+    return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) &&
+           L.match(RHS);
+  }
+};
+
+template<typename LHS>
+inline neg_match<LHS> m_Neg(const LHS &L) { return L; }
+
+
 //===----------------------------------------------------------------------===//
 // Matchers for control flow
 //

Modified: llvm/branches/non-call-eh/include/llvm/Support/Streams.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/Streams.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/Streams.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/Streams.h Sun Jul  6 15:45:41 2008
@@ -19,6 +19,9 @@
 
 namespace llvm {
 
+  /// FlushStream - Function called by BaseStream to flush an ostream.
+  void FlushStream(std::ostream &S);
+
   /// BaseStream - Acts like the STL streams. It's a wrapper for the std::cerr,
   /// std::cout, std::cin, etc. streams. However, it doesn't require #including
   /// @verbatim <iostream> @endverbatm in every file (doing so increases static 
@@ -39,6 +42,11 @@
       return *this;
     }
 
+    void flush() {
+      if (Stream)
+        FlushStream(*Stream);
+    }
+
     template <typename Ty>
     BaseStream &operator << (const Ty &Thing) {
       if (Stream) *Stream << Thing;

Modified: llvm/branches/non-call-eh/include/llvm/Support/Timer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Support/Timer.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Support/Timer.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Support/Timer.h Sun Jul  6 15:45:41 2008
@@ -30,7 +30,7 @@
 /// support it can also keep track of the RSS of the program at various points.
 /// By default, the Timer will print the amount of time it has captured to
 /// standard error when the laster timer is destroyed, otherwise it is printed
-/// when it's TimerGroup is destroyed.  Timer's do not print their information
+/// when its TimerGroup is destroyed.  Timers do not print their information
 /// if they are never started.
 ///
 class Timer {

Modified: llvm/branches/non-call-eh/include/llvm/System/Alarm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Alarm.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Alarm.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/Alarm.h Sun Jul  6 15:45:41 2008
@@ -17,8 +17,6 @@
 #ifndef LLVM_SYSTEM_ALARM_H
 #define LLVM_SYSTEM_ALARM_H
 
-#include "llvm/System/IncludeFile.h"
-
 namespace llvm {
 namespace sys {
 
@@ -44,6 +42,4 @@
 } // End sys namespace
 } // End llvm namespace
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SystemAlarm)
-
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/System/DynamicLibrary.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/DynamicLibrary.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/DynamicLibrary.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/DynamicLibrary.h Sun Jul  6 15:45:41 2008
@@ -15,7 +15,6 @@
 #define LLVM_SYSTEM_DYNAMIC_LIBRARY_H
 
 #include "llvm/System/Path.h"
-#include "llvm/System/IncludeFile.h"
 #include <string>
 
 namespace llvm {
@@ -96,6 +95,4 @@
 } // End sys namespace
 } // End llvm namespace
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SystemDynamicLibrary)
-
 #endif // LLVM_SYSTEM_DYNAMIC_LIBRARY_H

Modified: llvm/branches/non-call-eh/include/llvm/System/Memory.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Memory.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Memory.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/Memory.h Sun Jul  6 15:45:41 2008
@@ -15,7 +15,6 @@
 #define LLVM_SYSTEM_MEMORY_H
 
 #include <string>
-#include "llvm/System/IncludeFile.h"
 
 namespace llvm {
 namespace sys {
@@ -40,37 +39,38 @@
   /// @since 1.4
   /// @brief An abstraction for memory operations.
   class Memory {
-    /// @name Functions
-    /// @{
-    public:
-      /// This method allocates a block of Read/Write/Execute memory that is
-      /// suitable for executing dynamically generated code (e.g. JIT). An
-      /// attempt to allocate \p NumBytes bytes of virtual memory is made.
-      /// \p NearBlock may point to an existing allocation in which case
-      /// an attempt is made to allocate more memory near the existing block.
-      ///
-      /// On success, this returns a non-null memory block, otherwise it returns
-      /// a null memory block and fills in *ErrMsg.
-      /// 
-      /// @brief Allocate Read/Write/Execute memory.
-      static MemoryBlock AllocateRWX(unsigned NumBytes,
-                                     const MemoryBlock *NearBlock,
-                                     std::string *ErrMsg = 0);
-
-      /// This method releases a block of Read/Write/Execute memory that was
-      /// allocated with the AllocateRWX method. It should not be used to
-      /// release any memory block allocated any other way.
-      ///
-      /// On success, this returns false, otherwise it returns true and fills
-      /// in *ErrMsg.
-      /// @throws std::string if an error occurred.
-      /// @brief Release Read/Write/Execute memory.
-      static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = 0);
-    /// @}
+  public:
+    /// This method allocates a block of Read/Write/Execute memory that is
+    /// suitable for executing dynamically generated code (e.g. JIT). An
+    /// attempt to allocate \p NumBytes bytes of virtual memory is made.
+    /// \p NearBlock may point to an existing allocation in which case
+    /// an attempt is made to allocate more memory near the existing block.
+    ///
+    /// On success, this returns a non-null memory block, otherwise it returns
+    /// a null memory block and fills in *ErrMsg.
+    /// 
+    /// @brief Allocate Read/Write/Execute memory.
+    static MemoryBlock AllocateRWX(unsigned NumBytes,
+                                   const MemoryBlock *NearBlock,
+                                   std::string *ErrMsg = 0);
+
+    /// This method releases a block of Read/Write/Execute memory that was
+    /// allocated with the AllocateRWX method. It should not be used to
+    /// release any memory block allocated any other way.
+    ///
+    /// On success, this returns false, otherwise it returns true and fills
+    /// in *ErrMsg.
+    /// @throws std::string if an error occurred.
+    /// @brief Release Read/Write/Execute memory.
+    static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = 0);
+    
+    
+    /// InvalidateInstructionCache - Before the JIT can run a block of code
+    /// that has been emitted it must invalidate the instruction cache on some
+    /// platforms.
+    static void InvalidateInstructionCache(const void *Addr, size_t Len);
   };
 }
 }
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SystemMemory)
-
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Path.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Path.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/Path.h Sun Jul  6 15:45:41 2008
@@ -180,7 +180,7 @@
       /// of the path, use the isValid method.
       /// @param p The path to assign.
       /// @brief Construct a Path from a string.
-      explicit Path(const std::string& p) : path(p) {}
+      explicit Path(const std::string& p);
 
       /// This constructor will accept a character range as a path.  No checking
       /// is done on this path to determine if it is valid.  To determine
@@ -188,8 +188,7 @@
       /// @param StrStart A pointer to the first character of the path name
       /// @param StrLen The length of the path name at StrStart
       /// @brief Construct a Path from a string.
-      explicit Path(const char *StrStart, unsigned StrLen)
-        : path(StrStart, StrStart+StrLen) {}
+      Path(const char *StrStart, unsigned StrLen);
 
     /// @}
     /// @name Operators
@@ -206,16 +205,12 @@
       /// Compares \p this Path with \p that Path for equality.
       /// @returns true if \p this and \p that refer to the same thing.
       /// @brief Equality Operator
-      bool operator==(const Path &that) const {
-        return 0 == path.compare(that.path);
-      }
+      bool operator==(const Path &that) const;
 
       /// Compares \p this Path with \p that Path for inequality.
       /// @returns true if \p this and \p that refer to different things.
       /// @brief Inequality Operator
-      bool operator!=(const Path &that) const {
-        return 0 != path.compare(that.path);
-      }
+      bool operator!=(const Path &that) const;
 
       /// Determines if \p this Path is less than \p that Path. This is required
       /// so that Path objects can be placed into ordered collections (e.g.
@@ -223,9 +218,7 @@
       /// the std::string::compare method.
       /// @returns true if \p this path is lexicographically less than \p that.
       /// @brief Less Than Operator
-      bool operator<(const Path& that) const {
-        return 0 > path.compare(that.path);
-      }
+      bool operator<(const Path& that) const;
 
     /// @}
     /// @name Path Accessors
@@ -288,7 +281,7 @@
       const char *c_str() const { return path.c_str(); }
 
       /// size - Return the length in bytes of this path name.
-      unsigned size() const { return path.size(); }
+      size_t size() const { return path.size(); }
 
       /// empty - Returns true if the path is empty.
       unsigned empty() const { return path.empty(); }

Modified: llvm/branches/non-call-eh/include/llvm/System/Process.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Process.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Process.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/Process.h Sun Jul  6 15:45:41 2008
@@ -15,7 +15,6 @@
 #define LLVM_SYSTEM_PROCESS_H
 
 #include "llvm/System/TimeValue.h"
-#include "llvm/System/IncludeFile.h"
 
 namespace llvm {
 namespace sys {
@@ -100,6 +99,4 @@
 }
 }
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SystemProcess)
-
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/System/Program.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Program.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Program.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/Program.h Sun Jul  6 15:45:41 2008
@@ -15,8 +15,6 @@
 #define LLVM_SYSTEM_PROGRAM_H
 
 #include "llvm/System/Path.h"
-#include "llvm/System/IncludeFile.h"
-#include <vector>
 
 namespace llvm {
 namespace sys {
@@ -67,6 +65,9 @@
           ///< should have a size of at least three. If the pointer in the array
           ///< are not null, then the inferior process's stdin(0), stdout(1),
           ///< and stderr(2) will be redirected to the corresponding Paths.
+          ///< When an empty Path is passed in, the corresponding file
+          ///< descriptor will be disconnected (ie, /dev/null'd) in a portable
+          ///< way.
         unsigned secondsToWait = 0, ///< If non-zero, this specifies the amount
           ///< of time to wait for the child process to exit. If the time
           ///< expires, the child is killed and this call returns. If zero,
@@ -90,6 +91,4 @@
 }
 }
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SystemProgram)
-
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/System/Signals.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Signals.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Signals.h (original)
+++ llvm/branches/non-call-eh/include/llvm/System/Signals.h Sun Jul  6 15:45:41 2008
@@ -16,7 +16,6 @@
 #define LLVM_SYSTEM_SIGNALS_H
 
 #include "llvm/System/Path.h"
-#include "llvm/System/IncludeFile.h"
 
 namespace llvm {
 namespace sys {
@@ -50,6 +49,4 @@
 } // End sys namespace
 } // End llvm namespace
 
-FORCE_DEFINING_FILE_TO_BE_LINKED(SystemSignals)
-
 #endif

Added: llvm/branches/non-call-eh/include/llvm/System/Solaris.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/System/Solaris.h?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/System/Solaris.h (added)
+++ llvm/branches/non-call-eh/include/llvm/System/Solaris.h Sun Jul  6 15:45:41 2008
@@ -0,0 +1,40 @@
+/*===- llvm/System/Solaris.h ------------------------------------*- C++ -*-===*
+ *
+ *                     The LLVM Compiler Infrastructure
+ *
+ * This file is distributed under the University of Illinois Open Source
+ * License. See LICENSE.TXT for details.
+ *
+ *===----------------------------------------------------------------------===*
+ *
+ * This file contains portability fixes for Solaris hosts.
+ *
+ *===----------------------------------------------------------------------===*/
+
+#ifndef LLVM_SYSTEM_SOLARIS_H
+#define LLVM_SYSTEM_SOLARIS_H
+
+#include <sys/types.h>
+#include <sys/regset.h>
+
+#undef CS
+#undef DS
+#undef ES
+#undef FS
+#undef GS
+#undef SS
+#undef EAX
+#undef ECX
+#undef EDX
+#undef EBX
+#undef ESP
+#undef EBP
+#undef ESI
+#undef EDI
+#undef EIP
+#undef UESP
+#undef EFL
+#undef ERR
+#undef TRAPNO
+
+#endif

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetAsmInfo.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetAsmInfo.h Sun Jul  6 15:45:41 2008
@@ -16,7 +16,6 @@
 #ifndef LLVM_TARGET_ASM_INFO_H
 #define LLVM_TARGET_ASM_INFO_H
 
-#include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
@@ -29,8 +28,22 @@
     };
   }
 
+  namespace SectionKind {
+    enum Kind {
+      Text,             ///< Text section
+      Data,             ///< Data section
+      BSS,              ///< BSS section
+      ROData,           ///< Readonly data section
+      RODataMergeStr,   ///< Readonly data section (mergeable strings)
+      RODataMergeConst, ///< Readonly data section (mergeable constants)
+      ThreadData,       ///< Initialized TLS data objects
+      ThreadBSS         ///< Uninitialized TLS data objects
+    };
+  }
+
   class TargetMachine;
   class CallInst;
+  class GlobalValue;
 
   /// TargetAsmInfo - This class is intended to be used as a base class for asm
   /// properties and features specific to the target.
@@ -61,10 +74,16 @@
     /// Null if this target doesn't support a BSS section.
     ///
     const char *TLSBSSSection;// Default to ".section .tbss,"awT", at nobits".
+
     /// ZeroFillDirective - Directive for emitting a global to the ZeroFill
     /// section on this target.  Null if this target doesn't support zerofill.
     const char *ZeroFillDirective;        // Default is null.
     
+    /// NonexecutableStackDirective - Directive for declaring to the
+    /// linker and beyond that the emitted code does not require stack
+    /// memory to be executable.
+    const char *NonexecutableStackDirective; // Default is null.
+
     /// NeedsSet - True if target asm treats expressions in data directives
     /// as linktime-relocatable.  For assembly-time computation, we need to
     /// use a .set.  Thus:
@@ -141,6 +160,12 @@
     /// AssemblerDialect - Which dialect of an assembler variant to use.
     unsigned AssemblerDialect;            // Defaults to 0
 
+    /// StringConstantPrefix - Prefix for FEs to use when generating unnamed
+    /// constant strings.  These names get run through the Mangler later; if
+    /// you want the Mangler not to add the GlobalPrefix as well, 
+    /// use '\1' as the first character.
+    const char *StringConstantPrefix;     // Defaults to ".str"
+
     //===--- Data Emission Directives -------------------------------------===//
 
     /// ZeroDirective - this should be set to the directive used to get some
@@ -333,10 +358,6 @@
     /// handle a weak_definition of constant 0 for an omitted EH frame.
     bool SupportsWeakOmittedEHFrame;  // Defaults to true.
 
-    /// ShortenEHDataON64Bit - True if target exception table format requires
-    /// 32-bit data in certain places even when targeting 64-bits.
-    bool ShortenEHDataOn64Bit;    // Defaults to false.
-
     /// DwarfSectionOffsetDirective - Special section offset directive.
     const char* DwarfSectionOffsetDirective; // Defaults to NULL
     
@@ -391,7 +412,6 @@
     /// DwarfExceptionSection - Section directive for Exception table.
     ///
     const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
-     
 
     //===--- CBE Asm Translation Table -----------------------------------===//
 
@@ -419,7 +439,11 @@
     /// if the symbol can be relocated.
     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
                                            bool Global) const;
-    
+
+    /// SectionKindForGlobal - This hook allows the target to select proper
+    /// section kind used for global emission.
+    SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const;
+
     // Accessors.
     //
     const char *getTextSection() const {
@@ -440,6 +464,9 @@
     const char *getZeroFillDirective() const {
       return ZeroFillDirective;
     }
+    const char *getNonexecutableStackDirective() const {
+      return NonexecutableStackDirective;
+    }
     bool needsSet() const {
       return NeedsSet;
     }
@@ -491,6 +518,9 @@
     unsigned getAssemblerDialect() const {
       return AssemblerDialect;
     }
+    const char *getStringConstantPrefix() const {
+      return StringConstantPrefix;
+    }
     const char *getZeroDirective() const {
       return ZeroDirective;
     }
@@ -626,12 +656,9 @@
     bool getSupportsWeakOmittedEHFrame() const {
       return SupportsWeakOmittedEHFrame;
     }
-    bool getShortenEHDataOn64Bit() const {
-      return ShortenEHDataOn64Bit;
-    }
     const char *getDwarfSectionOffsetDirective() const {
       return DwarfSectionOffsetDirective;
-    }    
+    }
     const char *getDwarfAbbrevSection() const {
       return DwarfAbbrevSection;
     }

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetInstrDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetInstrDesc.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetInstrDesc.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetInstrDesc.h Sun Jul  6 15:45:41 2008
@@ -95,7 +95,8 @@
     Commutable,
     ConvertibleTo3Addr,
     UsesCustomDAGSchedInserter,
-    Rematerializable
+    Rematerializable,
+    CheapAsAMove
   };
 }
 
@@ -387,6 +388,15 @@
   bool isRematerializable() const {
     return Flags & (1 << TID::Rematerializable);
   }
+
+  /// isAsCheapAsAMove - Returns true if this instruction has the same cost (or
+  /// less) than a move instruction. This is useful during certain types of
+  /// rematerializations (e.g., during two-address conversion) where we would
+  /// like to remat the instruction, but not if it costs more than moving the
+  /// instruction into the appropriate register.
+  bool isAsCheapAsAMove() const {
+    return Flags & (1 << TID::CheapAsAMove);
+  }
 };
 
 } // end namespace llvm

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetInstrInfo.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetInstrInfo.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetInstrInfo.h Sun Jul  6 15:45:41 2008
@@ -46,12 +46,14 @@
   enum { 
     PHI = 0,
     INLINEASM = 1,
-    LABEL = 2,
-    DECLARE = 3,
-    EXTRACT_SUBREG = 4,
-    INSERT_SUBREG = 5,
-    IMPLICIT_DEF = 6,
-    SUBREG_TO_REG = 7
+    DBG_LABEL = 2,
+    EH_LABEL = 3,
+    GC_LABEL = 4,
+    DECLARE = 5,
+    EXTRACT_SUBREG = 6,
+    INSERT_SUBREG = 7,
+    IMPLICIT_DEF = 8,
+    SUBREG_TO_REG = 9
   };
 
   unsigned getNumOpcodes() const { return NumOpcodes; }
@@ -67,7 +69,7 @@
   /// isTriviallyReMaterializable - Return true if the instruction is trivially
   /// rematerializable, meaning it has no side effects and requires no operands
   /// that aren't always available.
-  bool isTriviallyReMaterializable(MachineInstr *MI) const {
+  bool isTriviallyReMaterializable(const MachineInstr *MI) const {
     return MI->getDesc().isRematerializable() &&
            isReallyTriviallyReMaterializable(MI);
   }
@@ -81,7 +83,7 @@
   /// return false if the instruction has any side effects other than
   /// producing a value, or if it requres any address registers that are not
   /// always available.
-  virtual bool isReallyTriviallyReMaterializable(MachineInstr *MI) const {
+  virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI) const {
     return true;
   }
 
@@ -141,7 +143,7 @@
   ///
   virtual MachineInstr *
   convertToThreeAddress(MachineFunction::iterator &MFI,
-                   MachineBasicBlock::iterator &MBBI, LiveVariables &LV) const {
+                   MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const {
     return 0;
   }
 
@@ -155,7 +157,10 @@
   /// return a new machine instruction.  If an instruction cannot commute, it
   /// can also return null.
   ///
-  virtual MachineInstr *commuteInstruction(MachineInstr *MI) const = 0;
+  /// If NewMI is true, then a new machine instruction must be created.
+  ///
+  virtual MachineInstr *commuteInstruction(MachineInstr *MI,
+                                           bool NewMI = false) const = 0;
 
   /// CommuteChangesDestination - Return true if commuting the specified
   /// instruction will also changes the destination operand. Also return the
@@ -411,7 +416,8 @@
   TargetInstrInfoImpl(const TargetInstrDesc *desc, unsigned NumOpcodes)
   : TargetInstrInfo(desc, NumOpcodes) {}
 public:
-  virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
+  virtual MachineInstr *commuteInstruction(MachineInstr *MI,
+                                           bool NewMI = false) const;
   virtual bool CommuteChangesDestination(MachineInstr *MI,
                                          unsigned &OpIdx) const;
   virtual bool PredicateInstruction(MachineInstr *MI,

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetJITInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetJITInfo.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetJITInfo.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetJITInfo.h Sun Jul  6 15:45:41 2008
@@ -17,7 +17,6 @@
 #ifndef LLVM_TARGET_TARGETJITINFO_H
 #define LLVM_TARGET_TARGETJITINFO_H
 
-#include <vector>
 #include <cassert>
 #include "llvm/Support/DataTypes.h"
 

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetLowering.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetLowering.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetLowering.h Sun Jul  6 15:45:41 2008
@@ -32,18 +32,19 @@
 #include <vector>
 
 namespace llvm {
-  class Value;
   class Function;
-  class TargetMachine;
-  class TargetData;
-  class TargetRegisterClass;
+  class MachineBasicBlock;
+  class MachineFrameInfo;
+  class MachineInstr;
   class SDNode;
   class SDOperand;
   class SelectionDAG;
-  class MachineBasicBlock;
-  class MachineInstr;
-  class VectorType;
+  class TargetData;
+  class TargetMachine;
+  class TargetRegisterClass;
   class TargetSubtarget;
+  class Value;
+  class VectorType;
 
 //===----------------------------------------------------------------------===//
 /// TargetLowering - This class defines information used to lower LLVM code to
@@ -89,8 +90,8 @@
 
   bool isBigEndian() const { return !IsLittleEndian; }
   bool isLittleEndian() const { return IsLittleEndian; }
-  MVT::ValueType getPointerTy() const { return PointerTy; }
-  MVT::ValueType getShiftAmountTy() const { return ShiftAmountTy; }
+  MVT getPointerTy() const { return PointerTy; }
+  MVT getShiftAmountTy() const { return ShiftAmountTy; }
   OutOfRangeShiftAmount getShiftAmountFlavor() const {return ShiftAmtHandling; }
 
   /// usesGlobalOffsetTable - Return true if this target uses a GOT for PIC
@@ -109,8 +110,9 @@
   /// srl/add/sra.
   bool isPow2DivCheap() const { return Pow2DivIsCheap; }
 
-  /// getSetCCResultType - Return the ValueType of the result of setcc operations.
-  virtual MVT::ValueType getSetCCResultType(const SDOperand &) const;
+  /// getSetCCResultType - Return the ValueType of the result of setcc
+  /// operations.
+  virtual MVT getSetCCResultType(const SDOperand &) const;
 
   /// getSetCCResultContents - For targets without boolean registers, this flag
   /// returns information about the contents of the high-bits in the setcc
@@ -124,19 +126,20 @@
 
   /// getRegClassFor - Return the register class that should be used for the
   /// specified value type.  This may only be called on legal types.
-  TargetRegisterClass *getRegClassFor(MVT::ValueType VT) const {
-    assert(VT < array_lengthof(RegClassForVT));
-    TargetRegisterClass *RC = RegClassForVT[VT];
+  TargetRegisterClass *getRegClassFor(MVT VT) const {
+    assert((unsigned)VT.getSimpleVT() < array_lengthof(RegClassForVT));
+    TargetRegisterClass *RC = RegClassForVT[VT.getSimpleVT()];
     assert(RC && "This value type is not natively supported!");
     return RC;
   }
-  
+
   /// isTypeLegal - Return true if the target has native support for the
   /// specified value type.  This means that it has a register that directly
   /// holds it without promotions or expansions.
-  bool isTypeLegal(MVT::ValueType VT) const {
-    assert(MVT::isExtendedVT(VT) || VT < array_lengthof(RegClassForVT));
-    return !MVT::isExtendedVT(VT) && RegClassForVT[VT] != 0;
+  bool isTypeLegal(MVT VT) const {
+    assert(!VT.isSimple() ||
+           (unsigned)VT.getSimpleVT() < array_lengthof(RegClassForVT));
+    return VT.isSimple() && RegClassForVT[VT.getSimpleVT()] != 0;
   }
 
   class ValueTypeActionImpl {
@@ -153,32 +156,35 @@
       ValueTypeActions[1] = RHS.ValueTypeActions[1];
     }
     
-    LegalizeAction getTypeAction(MVT::ValueType VT) const {
-      if (MVT::isExtendedVT(VT)) {
-        if (MVT::isVector(VT)) return Expand;
-        if (MVT::isInteger(VT))
+    LegalizeAction getTypeAction(MVT VT) const {
+      if (VT.isExtended()) {
+        if (VT.isVector()) return Expand;
+        if (VT.isInteger())
           // First promote to a power-of-two size, then expand if necessary.
-          return VT == MVT::RoundIntegerType(VT) ? Expand : Promote;
+          return VT == VT.getRoundIntegerType() ? Expand : Promote;
         assert(0 && "Unsupported extended type!");
+        return Legal;
       }
-      assert(VT<4*array_lengthof(ValueTypeActions)*sizeof(ValueTypeActions[0]));
-      return (LegalizeAction)((ValueTypeActions[VT>>4] >> ((2*VT) & 31)) & 3);
+      unsigned I = VT.getSimpleVT();
+      assert(I<4*array_lengthof(ValueTypeActions)*sizeof(ValueTypeActions[0]));
+      return (LegalizeAction)((ValueTypeActions[I>>4] >> ((2*I) & 31)) & 3);
     }
-    void setTypeAction(MVT::ValueType VT, LegalizeAction Action) {
-      assert(VT<4*array_lengthof(ValueTypeActions)*sizeof(ValueTypeActions[0]));
-      ValueTypeActions[VT>>4] |= Action << ((VT*2) & 31);
+    void setTypeAction(MVT VT, LegalizeAction Action) {
+      unsigned I = VT.getSimpleVT();
+      assert(I<4*array_lengthof(ValueTypeActions)*sizeof(ValueTypeActions[0]));
+      ValueTypeActions[I>>4] |= Action << ((I*2) & 31);
     }
   };
   
   const ValueTypeActionImpl &getValueTypeActions() const {
     return ValueTypeActions;
   }
-  
+
   /// getTypeAction - Return how we should legalize values of this type, either
   /// it is already legal (return 'Legal') or we need to promote it to a larger
   /// type (return 'Promote'), or we need to expand it into multiple registers
   /// of smaller integer type (return 'Expand').  'Custom' is not an option.
-  LegalizeAction getTypeAction(MVT::ValueType VT) const {
+  LegalizeAction getTypeAction(MVT VT) const {
     return ValueTypeActions.getTypeAction(VT);
   }
 
@@ -188,37 +194,37 @@
   /// than the largest integer register, this contains one step in the expansion
   /// to get to the smaller register. For illegal floating point types, this
   /// returns the integer type to transform to.
-  MVT::ValueType getTypeToTransformTo(MVT::ValueType VT) const {
-    if (!MVT::isExtendedVT(VT)) {
-      assert(VT < array_lengthof(TransformToType));
-      MVT::ValueType NVT = TransformToType[VT];
+  MVT getTypeToTransformTo(MVT VT) const {
+    if (VT.isSimple()) {
+      assert((unsigned)VT.getSimpleVT() < array_lengthof(TransformToType));
+      MVT NVT = TransformToType[VT.getSimpleVT()];
       assert(getTypeAction(NVT) != Promote &&
              "Promote may not follow Expand or Promote");
       return NVT;
     }
 
-    if (MVT::isVector(VT))
-      return MVT::getVectorType(MVT::getVectorElementType(VT),
-                                MVT::getVectorNumElements(VT) / 2);
-    if (MVT::isInteger(VT)) {
-      MVT::ValueType NVT = MVT::RoundIntegerType(VT);
+    if (VT.isVector())
+      return MVT::getVectorVT(VT.getVectorElementType(),
+                              VT.getVectorNumElements() / 2);
+    if (VT.isInteger()) {
+      MVT NVT = VT.getRoundIntegerType();
       if (NVT == VT)
         // Size is a power of two - expand to half the size.
-        return MVT::getIntegerType(MVT::getSizeInBits(VT) / 2);
+        return MVT::getIntegerVT(VT.getSizeInBits() / 2);
       else
         // Promote to a power of two size, avoiding multi-step promotion.
         return getTypeAction(NVT) == Promote ? getTypeToTransformTo(NVT) : NVT;
     }
     assert(0 && "Unsupported extended type!");
-    return MVT::ValueType(); // Not reached
+    return MVT(); // Not reached
   }
 
   /// getTypeToExpandTo - For types supported by the target, this is an
   /// identity function.  For types that must be expanded (i.e. integer types
   /// that are larger than the largest integer register or illegal floating
   /// point types), this returns the largest legal type it will be expanded to.
-  MVT::ValueType getTypeToExpandTo(MVT::ValueType VT) const {
-    assert(!MVT::isVector(VT));
+  MVT getTypeToExpandTo(MVT VT) const {
+    assert(!VT.isVector());
     while (true) {
       switch (getTypeAction(VT)) {
       case Legal:
@@ -243,10 +249,10 @@
   /// register.  It also returns the VT and quantity of the intermediate values
   /// before they are promoted/expanded.
   ///
-  unsigned getVectorTypeBreakdown(MVT::ValueType VT, 
-                                  MVT::ValueType &IntermediateVT,
+  unsigned getVectorTypeBreakdown(MVT VT,
+                                  MVT &IntermediateVT,
                                   unsigned &NumIntermediates,
-                                  MVT::ValueType &RegisterVT) const;
+                                  MVT &RegisterVT) const;
   
   typedef std::vector<APFloat>::const_iterator legal_fpimm_iterator;
   legal_fpimm_iterator legal_fpimm_begin() const {
@@ -260,7 +266,7 @@
   /// support *some* VECTOR_SHUFFLE operations, those with specific masks.
   /// By default, if a target supports the VECTOR_SHUFFLE node, all mask values
   /// are assumed to be legal.
-  virtual bool isShuffleMaskLegal(SDOperand Mask, MVT::ValueType VT) const {
+  virtual bool isShuffleMaskLegal(SDOperand Mask, MVT VT) const {
     return true;
   }
 
@@ -269,7 +275,7 @@
   /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant
   /// pool entry.
   virtual bool isVectorClearMaskLegal(const std::vector<SDOperand> &BVOps,
-                                      MVT::ValueType EVT,
+                                      MVT EVT,
                                       SelectionDAG &DAG) const {
     return false;
   }
@@ -278,53 +284,58 @@
   /// it is legal, needs to be promoted to a larger size, needs to be
   /// expanded to some other code sequence, or the target has a custom expander
   /// for it.
-  LegalizeAction getOperationAction(unsigned Op, MVT::ValueType VT) const {
-    if (MVT::isExtendedVT(VT)) return Expand;
+  LegalizeAction getOperationAction(unsigned Op, MVT VT) const {
+    if (VT.isExtended()) return Expand;
     assert(Op < array_lengthof(OpActions) &&
-           VT < sizeof(OpActions[0])*4 && "Table isn't big enough!");
-    return (LegalizeAction)((OpActions[Op] >> (2*VT)) & 3);
+           (unsigned)VT.getSimpleVT() < sizeof(OpActions[0])*4 &&
+           "Table isn't big enough!");
+    return (LegalizeAction)((OpActions[Op] >> (2*VT.getSimpleVT())) & 3);
   }
-  
+
   /// isOperationLegal - Return true if the specified operation is legal on this
   /// target.
-  bool isOperationLegal(unsigned Op, MVT::ValueType VT) const {
-    return getOperationAction(Op, VT) == Legal ||
-           getOperationAction(Op, VT) == Custom;
+  bool isOperationLegal(unsigned Op, MVT VT) const {
+    return (VT == MVT::Other || isTypeLegal(VT)) &&
+      (getOperationAction(Op, VT) == Legal ||
+       getOperationAction(Op, VT) == Custom);
   }
-  
+
   /// getLoadXAction - Return how this load with extension should be treated:
   /// either it is legal, needs to be promoted to a larger size, needs to be
   /// expanded to some other code sequence, or the target has a custom expander
   /// for it.
-  LegalizeAction getLoadXAction(unsigned LType, MVT::ValueType VT) const {
+  LegalizeAction getLoadXAction(unsigned LType, MVT VT) const {
     assert(LType < array_lengthof(LoadXActions) &&
-           VT < sizeof(LoadXActions[0])*4 && "Table isn't big enough!");
-    return (LegalizeAction)((LoadXActions[LType] >> (2*VT)) & 3);
+           (unsigned)VT.getSimpleVT() < sizeof(LoadXActions[0])*4 &&
+           "Table isn't big enough!");
+    return (LegalizeAction)((LoadXActions[LType] >> (2*VT.getSimpleVT())) & 3);
   }
-  
+
   /// isLoadXLegal - Return true if the specified load with extension is legal
   /// on this target.
-  bool isLoadXLegal(unsigned LType, MVT::ValueType VT) const {
-    return !MVT::isExtendedVT(VT) &&
+  bool isLoadXLegal(unsigned LType, MVT VT) const {
+    return VT.isSimple() &&
       (getLoadXAction(LType, VT) == Legal ||
        getLoadXAction(LType, VT) == Custom);
   }
-  
+
   /// getTruncStoreAction - Return how this store with truncation should be
   /// treated: either it is legal, needs to be promoted to a larger size, needs
   /// to be expanded to some other code sequence, or the target has a custom
   /// expander for it.
-  LegalizeAction getTruncStoreAction(MVT::ValueType ValVT, 
-                                     MVT::ValueType MemVT) const {
-    assert(ValVT < array_lengthof(TruncStoreActions) && 
-           MemVT < sizeof(TruncStoreActions[0])*4 && "Table isn't big enough!");
-    return (LegalizeAction)((TruncStoreActions[ValVT] >> (2*MemVT)) & 3);
+  LegalizeAction getTruncStoreAction(MVT ValVT,
+                                     MVT MemVT) const {
+    assert((unsigned)ValVT.getSimpleVT() < array_lengthof(TruncStoreActions) &&
+           (unsigned)MemVT.getSimpleVT() < sizeof(TruncStoreActions[0])*4 &&
+           "Table isn't big enough!");
+    return (LegalizeAction)((TruncStoreActions[ValVT.getSimpleVT()] >>
+                             (2*MemVT.getSimpleVT())) & 3);
   }
-  
+
   /// isTruncStoreLegal - Return true if the specified store with truncation is
   /// legal on this target.
-  bool isTruncStoreLegal(MVT::ValueType ValVT, MVT::ValueType MemVT) const {
-    return !MVT::isExtendedVT(MemVT) &&
+  bool isTruncStoreLegal(MVT ValVT, MVT MemVT) const {
+    return isTypeLegal(ValVT) && MemVT.isSimple() &&
       (getTruncStoreAction(ValVT, MemVT) == Legal ||
        getTruncStoreAction(ValVT, MemVT) == Custom);
   }
@@ -334,88 +345,95 @@
   /// expanded to some other code sequence, or the target has a custom expander
   /// for it.
   LegalizeAction
-  getIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT) const {
+  getIndexedLoadAction(unsigned IdxMode, MVT VT) const {
     assert(IdxMode < array_lengthof(IndexedModeActions[0]) &&
-           VT < sizeof(IndexedModeActions[0][0])*4 &&
+           (unsigned)VT.getSimpleVT() < sizeof(IndexedModeActions[0][0])*4 &&
            "Table isn't big enough!");
-    return (LegalizeAction)((IndexedModeActions[0][IdxMode] >> (2*VT)) & 3);
+    return (LegalizeAction)((IndexedModeActions[0][IdxMode] >>
+                             (2*VT.getSimpleVT())) & 3);
   }
 
   /// isIndexedLoadLegal - Return true if the specified indexed load is legal
   /// on this target.
-  bool isIndexedLoadLegal(unsigned IdxMode, MVT::ValueType VT) const {
-    return getIndexedLoadAction(IdxMode, VT) == Legal ||
-           getIndexedLoadAction(IdxMode, VT) == Custom;
+  bool isIndexedLoadLegal(unsigned IdxMode, MVT VT) const {
+    return VT.isSimple() &&
+      (getIndexedLoadAction(IdxMode, VT) == Legal ||
+       getIndexedLoadAction(IdxMode, VT) == Custom);
   }
-  
+
   /// getIndexedStoreAction - Return how the indexed store should be treated:
   /// either it is legal, needs to be promoted to a larger size, needs to be
   /// expanded to some other code sequence, or the target has a custom expander
   /// for it.
   LegalizeAction
-  getIndexedStoreAction(unsigned IdxMode, MVT::ValueType VT) const {
+  getIndexedStoreAction(unsigned IdxMode, MVT VT) const {
     assert(IdxMode < array_lengthof(IndexedModeActions[1]) &&
-           VT < sizeof(IndexedModeActions[1][0])*4 &&
+           (unsigned)VT.getSimpleVT() < sizeof(IndexedModeActions[1][0])*4 &&
            "Table isn't big enough!");
-    return (LegalizeAction)((IndexedModeActions[1][IdxMode] >> (2*VT)) & 3);
+    return (LegalizeAction)((IndexedModeActions[1][IdxMode] >>
+                             (2*VT.getSimpleVT())) & 3);
   }  
-  
+
   /// isIndexedStoreLegal - Return true if the specified indexed load is legal
   /// on this target.
-  bool isIndexedStoreLegal(unsigned IdxMode, MVT::ValueType VT) const {
-    return getIndexedStoreAction(IdxMode, VT) == Legal ||
-           getIndexedStoreAction(IdxMode, VT) == Custom;
+  bool isIndexedStoreLegal(unsigned IdxMode, MVT VT) const {
+    return VT.isSimple() &&
+      (getIndexedStoreAction(IdxMode, VT) == Legal ||
+       getIndexedStoreAction(IdxMode, VT) == Custom);
   }
-  
+
   /// getConvertAction - Return how the conversion should be treated:
   /// either it is legal, needs to be promoted to a larger size, needs to be
   /// expanded to some other code sequence, or the target has a custom expander
   /// for it.
   LegalizeAction
-  getConvertAction(MVT::ValueType FromVT, MVT::ValueType ToVT) const {
-    assert(FromVT < array_lengthof(ConvertActions) && 
-           ToVT < sizeof(ConvertActions[0])*4 && "Table isn't big enough!");
-    return (LegalizeAction)((ConvertActions[FromVT] >> (2*ToVT)) & 3);
+  getConvertAction(MVT FromVT, MVT ToVT) const {
+    assert((unsigned)FromVT.getSimpleVT() < array_lengthof(ConvertActions) &&
+           (unsigned)ToVT.getSimpleVT() < sizeof(ConvertActions[0])*4 &&
+           "Table isn't big enough!");
+    return (LegalizeAction)((ConvertActions[FromVT.getSimpleVT()] >>
+                             (2*ToVT.getSimpleVT())) & 3);
   }
 
   /// isConvertLegal - Return true if the specified conversion is legal
   /// on this target.
-  bool isConvertLegal(MVT::ValueType FromVT, MVT::ValueType ToVT) const {
-    return getConvertAction(FromVT, ToVT) == Legal ||
-           getConvertAction(FromVT, ToVT) == Custom;
+  bool isConvertLegal(MVT FromVT, MVT ToVT) const {
+    return isTypeLegal(FromVT) && isTypeLegal(ToVT) &&
+      (getConvertAction(FromVT, ToVT) == Legal ||
+       getConvertAction(FromVT, ToVT) == Custom);
   }
 
   /// getTypeToPromoteTo - If the action for this operation is to promote, this
   /// method returns the ValueType to promote to.
-  MVT::ValueType getTypeToPromoteTo(unsigned Op, MVT::ValueType VT) const {
+  MVT getTypeToPromoteTo(unsigned Op, MVT VT) const {
     assert(getOperationAction(Op, VT) == Promote &&
            "This operation isn't promoted!");
 
     // See if this has an explicit type specified.
-    std::map<std::pair<unsigned, MVT::ValueType>, 
-             MVT::ValueType>::const_iterator PTTI =
-      PromoteToType.find(std::make_pair(Op, VT));
+    std::map<std::pair<unsigned, MVT::SimpleValueType>,
+             MVT::SimpleValueType>::const_iterator PTTI =
+      PromoteToType.find(std::make_pair(Op, VT.getSimpleVT()));
     if (PTTI != PromoteToType.end()) return PTTI->second;
-    
-    assert((MVT::isInteger(VT) || MVT::isFloatingPoint(VT)) &&
+
+    assert((VT.isInteger() || VT.isFloatingPoint()) &&
            "Cannot autopromote this type, add it with AddPromotedToType.");
     
-    MVT::ValueType NVT = VT;
+    MVT NVT = VT;
     do {
-      NVT = (MVT::ValueType)(NVT+1);
-      assert(MVT::isInteger(NVT) == MVT::isInteger(VT) && NVT != MVT::isVoid &&
+      NVT = (MVT::SimpleValueType)(NVT.getSimpleVT()+1);
+      assert(NVT.isInteger() == VT.isInteger() && NVT != MVT::isVoid &&
              "Didn't find type to promote to!");
     } while (!isTypeLegal(NVT) ||
               getOperationAction(Op, NVT) == Promote);
     return NVT;
   }
 
-  /// getValueType - Return the MVT::ValueType corresponding to this LLVM type.
+  /// getValueType - Return the MVT corresponding to this LLVM type.
   /// This is fixed by the LLVM operations except for the pointer size.  If
   /// AllowUnknown is true, this will return MVT::Other for types with no MVT
   /// counterpart (e.g. structs), otherwise it will assert.
-  MVT::ValueType getValueType(const Type *Ty, bool AllowUnknown = false) const {
-    MVT::ValueType VT = MVT::getValueType(Ty, AllowUnknown);
+  MVT getValueType(const Type *Ty, bool AllowUnknown = false) const {
+    MVT VT = MVT::getMVT(Ty, AllowUnknown);
     return VT == MVT::iPTR ? PointerTy : VT;
   }
 
@@ -426,22 +444,22 @@
   
   /// getRegisterType - Return the type of registers that this ValueType will
   /// eventually require.
-  MVT::ValueType getRegisterType(MVT::ValueType VT) const {
-    if (!MVT::isExtendedVT(VT)) {
-      assert(VT < array_lengthof(RegisterTypeForVT));
-      return RegisterTypeForVT[VT];
+  MVT getRegisterType(MVT VT) const {
+    if (VT.isSimple()) {
+      assert((unsigned)VT.getSimpleVT() < array_lengthof(RegisterTypeForVT));
+      return RegisterTypeForVT[VT.getSimpleVT()];
     }
-    if (MVT::isVector(VT)) {
-      MVT::ValueType VT1, RegisterVT;
+    if (VT.isVector()) {
+      MVT VT1, RegisterVT;
       unsigned NumIntermediates;
       (void)getVectorTypeBreakdown(VT, VT1, NumIntermediates, RegisterVT);
       return RegisterVT;
     }
-    if (MVT::isInteger(VT)) {
+    if (VT.isInteger()) {
       return getRegisterType(getTypeToTransformTo(VT));
     }
     assert(0 && "Unsupported extended type!");
-    return MVT::ValueType(); // Not reached
+    return MVT(); // Not reached
   }
 
   /// getNumRegisters - Return the number of registers that this ValueType will
@@ -450,19 +468,19 @@
   /// into pieces.  For types like i140, which are first promoted then expanded,
   /// it is the number of registers needed to hold all the bits of the original
   /// type.  For an i140 on a 32 bit machine this means 5 registers.
-  unsigned getNumRegisters(MVT::ValueType VT) const {
-    if (!MVT::isExtendedVT(VT)) {
-      assert(VT < array_lengthof(NumRegistersForVT));
-      return NumRegistersForVT[VT];
+  unsigned getNumRegisters(MVT VT) const {
+    if (VT.isSimple()) {
+      assert((unsigned)VT.getSimpleVT() < array_lengthof(NumRegistersForVT));
+      return NumRegistersForVT[VT.getSimpleVT()];
     }
-    if (MVT::isVector(VT)) {
-      MVT::ValueType VT1, VT2;
+    if (VT.isVector()) {
+      MVT VT1, VT2;
       unsigned NumIntermediates;
       return getVectorTypeBreakdown(VT, VT1, NumIntermediates, VT2);
     }
-    if (MVT::isInteger(VT)) {
-      unsigned BitWidth = MVT::getSizeInBits(VT);
-      unsigned RegWidth = MVT::getSizeInBits(getRegisterType(VT));
+    if (VT.isInteger()) {
+      unsigned BitWidth = VT.getSizeInBits();
+      unsigned RegWidth = getRegisterType(VT).getSizeInBits();
       return (BitWidth + RegWidth - 1) / RegWidth;
     }
     assert(0 && "Unsupported extended type!");
@@ -472,7 +490,7 @@
   /// ShouldShrinkFPConstant - If true, then instruction selection should
   /// seek to shrink the FP constant of the specified type to a smaller type
   /// in order to save space and / or reduce runtime.
-  virtual bool ShouldShrinkFPConstant(MVT::ValueType VT) const { return true; }
+  virtual bool ShouldShrinkFPConstant(MVT VT) const { return true; }
 
   /// hasTargetDAGCombine - If true, the target has custom DAG combine
   /// transformations that it can perform for the specified node.
@@ -508,6 +526,15 @@
   bool allowsUnalignedMemoryAccesses() const {
     return allowUnalignedMemoryAccesses;
   }
+
+  /// getOptimalMemOpType - Returns the target specific optimal type for load
+  /// and store operations as a result of memset, memcpy, and memmove lowering.
+  /// It returns MVT::iAny if SelectionDAG should be responsible for
+  /// determining it.
+  virtual MVT getOptimalMemOpType(uint64_t Size, unsigned Align,
+                                  bool isSrcConst, bool isSrcStr) const {
+    return MVT::iAny;
+  }
   
   /// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
   /// to implement llvm.setjmp.
@@ -676,10 +703,21 @@
 
   /// SimplifySetCC - Try to simplify a setcc built with the specified operands 
   /// and cc. If it is unable to simplify it, return a null SDOperand.
-  SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N0, SDOperand N1,
+  SDOperand SimplifySetCC(MVT VT, SDOperand N0, SDOperand N1,
                           ISD::CondCode Cond, bool foldBooleans,
                           DAGCombinerInfo &DCI) const;
 
+  /// isGAPlusOffset - Returns true (and the GlobalValue and the offset) if the
+  /// node is a GlobalAddress + offset.
+  virtual bool
+  isGAPlusOffset(SDNode *N, GlobalValue* &GA, int64_t &Offset) const;
+
+  /// isConsecutiveLoad - Return true if LD (which must be a LoadSDNode) is
+  /// loading 'Bytes' bytes from a location that is 'Dist' units away from the
+  /// location that the 'Base' load is loading from.
+  bool isConsecutiveLoad(SDNode *LD, SDNode *Base, unsigned Bytes, int Dist,
+                         const MachineFrameInfo *MFI) const;
+
   /// PerformDAGCombine - This method will be invoked for all target nodes and
   /// for any target-independent nodes that the target has registered with
   /// invoke it for.
@@ -707,7 +745,7 @@
 
   /// setShiftAmountType - Describe the type that should be used for shift
   /// amounts.  This type defaults to the pointer type.
-  void setShiftAmountType(MVT::ValueType VT) { ShiftAmountTy = VT; }
+  void setShiftAmountType(MVT VT) { ShiftAmountTy = VT; }
 
   /// setSetCCResultContents - Specify how the target extends the result of a
   /// setcc operation in a register.
@@ -776,10 +814,10 @@
   /// addRegisterClass - Add the specified register class as an available
   /// regclass for the specified value type.  This indicates the selector can
   /// handle values of that class natively.
-  void addRegisterClass(MVT::ValueType VT, TargetRegisterClass *RC) {
-    assert(VT < array_lengthof(RegClassForVT));
+  void addRegisterClass(MVT VT, TargetRegisterClass *RC) {
+    assert((unsigned)VT.getSimpleVT() < array_lengthof(RegClassForVT));
     AvailableRegClasses.push_back(std::make_pair(VT, RC));
-    RegClassForVT[VT] = RC;
+    RegClassForVT[VT.getSimpleVT()] = RC;
   }
 
   /// computeRegisterProperties - Once all of the register classes are added,
@@ -788,78 +826,84 @@
 
   /// setOperationAction - Indicate that the specified operation does not work
   /// with the specified type and indicate what to do about it.
-  void setOperationAction(unsigned Op, MVT::ValueType VT,
+  void setOperationAction(unsigned Op, MVT VT,
                           LegalizeAction Action) {
-    assert(VT < sizeof(OpActions[0])*4 && Op < array_lengthof(OpActions) &&
-           "Table isn't big enough!");
-    OpActions[Op] &= ~(uint64_t(3UL) << VT*2);
-    OpActions[Op] |= (uint64_t)Action << VT*2;
+    assert((unsigned)VT.getSimpleVT() < sizeof(OpActions[0])*4 &&
+           Op < array_lengthof(OpActions) && "Table isn't big enough!");
+    OpActions[Op] &= ~(uint64_t(3UL) << VT.getSimpleVT()*2);
+    OpActions[Op] |= (uint64_t)Action << VT.getSimpleVT()*2;
   }
   
   /// setLoadXAction - Indicate that the specified load with extension does not
   /// work with the with specified type and indicate what to do about it.
-  void setLoadXAction(unsigned ExtType, MVT::ValueType VT,
+  void setLoadXAction(unsigned ExtType, MVT VT,
                       LegalizeAction Action) {
-    assert(VT < sizeof(LoadXActions[0])*4 && 
+    assert((unsigned)VT.getSimpleVT() < sizeof(LoadXActions[0])*4 &&
            ExtType < array_lengthof(LoadXActions) &&
            "Table isn't big enough!");
-    LoadXActions[ExtType] &= ~(uint64_t(3UL) << VT*2);
-    LoadXActions[ExtType] |= (uint64_t)Action << VT*2;
+    LoadXActions[ExtType] &= ~(uint64_t(3UL) << VT.getSimpleVT()*2);
+    LoadXActions[ExtType] |= (uint64_t)Action << VT.getSimpleVT()*2;
   }
   
   /// setTruncStoreAction - Indicate that the specified truncating store does
   /// not work with the with specified type and indicate what to do about it.
-  void setTruncStoreAction(MVT::ValueType ValVT, MVT::ValueType MemVT,
+  void setTruncStoreAction(MVT ValVT, MVT MemVT,
                            LegalizeAction Action) {
-    assert(ValVT < array_lengthof(TruncStoreActions) && 
-           MemVT < sizeof(TruncStoreActions[0])*4 && "Table isn't big enough!");
-    TruncStoreActions[ValVT] &= ~(uint64_t(3UL) << MemVT*2);
-    TruncStoreActions[ValVT] |= (uint64_t)Action << MemVT*2;
+    assert((unsigned)ValVT.getSimpleVT() < array_lengthof(TruncStoreActions) &&
+           (unsigned)MemVT.getSimpleVT() < sizeof(TruncStoreActions[0])*4 &&
+           "Table isn't big enough!");
+    TruncStoreActions[ValVT.getSimpleVT()] &= ~(uint64_t(3UL) <<
+                                                MemVT.getSimpleVT()*2);
+    TruncStoreActions[ValVT.getSimpleVT()] |= (uint64_t)Action <<
+      MemVT.getSimpleVT()*2;
   }
 
   /// setIndexedLoadAction - Indicate that the specified indexed load does or
   /// does not work with the with specified type and indicate what to do abort
   /// it. NOTE: All indexed mode loads are initialized to Expand in
   /// TargetLowering.cpp
-  void setIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT,
+  void setIndexedLoadAction(unsigned IdxMode, MVT VT,
                             LegalizeAction Action) {
-    assert(VT < sizeof(IndexedModeActions[0])*4 && IdxMode <
-           array_lengthof(IndexedModeActions[0]) &&
+    assert((unsigned)VT.getSimpleVT() < sizeof(IndexedModeActions[0])*4 &&
+           IdxMode < array_lengthof(IndexedModeActions[0]) &&
            "Table isn't big enough!");
-    IndexedModeActions[0][IdxMode] &= ~(uint64_t(3UL) << VT*2);
-    IndexedModeActions[0][IdxMode] |= (uint64_t)Action << VT*2;
+    IndexedModeActions[0][IdxMode] &= ~(uint64_t(3UL) << VT.getSimpleVT()*2);
+    IndexedModeActions[0][IdxMode] |= (uint64_t)Action << VT.getSimpleVT()*2;
   }
   
   /// setIndexedStoreAction - Indicate that the specified indexed store does or
   /// does not work with the with specified type and indicate what to do about
   /// it. NOTE: All indexed mode stores are initialized to Expand in
   /// TargetLowering.cpp
-  void setIndexedStoreAction(unsigned IdxMode, MVT::ValueType VT,
+  void setIndexedStoreAction(unsigned IdxMode, MVT VT,
                              LegalizeAction Action) {
-    assert(VT < sizeof(IndexedModeActions[1][0])*4 &&
+    assert((unsigned)VT.getSimpleVT() < sizeof(IndexedModeActions[1][0])*4 &&
            IdxMode < array_lengthof(IndexedModeActions[1]) &&
            "Table isn't big enough!");
-    IndexedModeActions[1][IdxMode] &= ~(uint64_t(3UL) << VT*2);
-    IndexedModeActions[1][IdxMode] |= (uint64_t)Action << VT*2;
+    IndexedModeActions[1][IdxMode] &= ~(uint64_t(3UL) << VT.getSimpleVT()*2);
+    IndexedModeActions[1][IdxMode] |= (uint64_t)Action << VT.getSimpleVT()*2;
   }
   
   /// setConvertAction - Indicate that the specified conversion does or does
   /// not work with the with specified type and indicate what to do about it.
-  void setConvertAction(MVT::ValueType FromVT, MVT::ValueType ToVT, 
+  void setConvertAction(MVT FromVT, MVT ToVT,
                         LegalizeAction Action) {
-    assert(FromVT < array_lengthof(ConvertActions) &&
-           ToVT < sizeof(ConvertActions[0])*4 && "Table isn't big enough!");
-    ConvertActions[FromVT] &= ~(uint64_t(3UL) << ToVT*2);
-    ConvertActions[FromVT] |= (uint64_t)Action << ToVT*2;
+    assert((unsigned)FromVT.getSimpleVT() < array_lengthof(ConvertActions) &&
+           (unsigned)ToVT.getSimpleVT() < sizeof(ConvertActions[0])*4 &&
+           "Table isn't big enough!");
+    ConvertActions[FromVT.getSimpleVT()] &= ~(uint64_t(3UL) <<
+                                              ToVT.getSimpleVT()*2);
+    ConvertActions[FromVT.getSimpleVT()] |= (uint64_t)Action <<
+      ToVT.getSimpleVT()*2;
   }
 
   /// AddPromotedToType - If Opc/OrigVT is specified as being promoted, the
   /// promotion code defaults to trying a larger integer/fp until it can find
   /// one that works.  If that default is insufficient, this method can be used
   /// by the target to override the default.
-  void AddPromotedToType(unsigned Opc, MVT::ValueType OrigVT, 
-                         MVT::ValueType DestVT) {
-    PromoteToType[std::make_pair(Opc, OrigVT)] = DestVT;
+  void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT) {
+    PromoteToType[std::make_pair(Opc, OrigVT.getSimpleVT())] =
+      DestVT.getSimpleVT();
   }
 
   /// addLegalFPImmediate - Indicate that this target can instruction select
@@ -920,8 +964,9 @@
 
   /// LowerArguments - This hook must be implemented to indicate how we should
   /// lower the arguments for the specified function, into the specified DAG.
-  virtual std::vector<SDOperand>
-  LowerArguments(Function &F, SelectionDAG &DAG);
+  virtual void
+  LowerArguments(Function &F, SelectionDAG &DAG,
+                 SmallVectorImpl<SDOperand>& ArgValues);
 
   /// LowerCallTo - This hook lowers an abstract call to a function into an
   /// actual call.  This returns a pair of operands.  The first element is the
@@ -930,12 +975,12 @@
   struct ArgListEntry {
     SDOperand Node;
     const Type* Ty;
-    bool isSExt;
-    bool isZExt;
-    bool isInReg;
-    bool isSRet;
-    bool isNest;
-    bool isByVal;
+    bool isSExt  : 1;
+    bool isZExt  : 1;
+    bool isInReg : 1;
+    bool isSRet  : 1;
+    bool isNest  : 1;
+    bool isByVal : 1;
     uint16_t Alignment;
 
     ArgListEntry() : isSExt(false), isZExt(false), isInReg(false),
@@ -1010,19 +1055,19 @@
   /// implement this.  The default implementation of this aborts.
   virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
 
-  /// ExpandOperationResult - This callback is invoked for operations that are 
+  /// ReplaceNodeResults - This callback is invoked for operations that are
   /// unsupported by the target, which are registered to use 'custom' lowering,
-  /// and whose result type needs to be expanded.  This must return a node whose
-  /// results precisely match the results of the input node.  This typically
-  /// involves a MERGE_VALUES node and/or BUILD_PAIR.
+  /// and whose result type is illegal.  This must return a node whose results
+  /// precisely match the results of the input node.  This typically involves a
+  /// MERGE_VALUES node and/or BUILD_PAIR.
   ///
   /// If the target has no operations that require custom lowering, it need not
-  /// implement this.  The default implementation of this aborts.
-  virtual SDNode *ExpandOperationResult(SDNode *N, SelectionDAG &DAG) {
-    assert(0 && "ExpandOperationResult not implemented for this target!");
+  /// implement this.  The default implementation aborts.
+  virtual SDNode *ReplaceNodeResults(SDNode *N, SelectionDAG &DAG) {
+    assert(0 && "ReplaceNodeResults not implemented for this target!");
     return 0;
   }
-  
+
   /// IsEligibleForTailCallOptimization - Check whether the call is eligible for
   /// tail call optimization. Targets which want to do tail call optimization
   /// should override this function. 
@@ -1032,11 +1077,36 @@
     return false;
   }
 
-  /// CustomPromoteOperation - This callback is invoked for operations that are
-  /// unsupported by the target, are registered to use 'custom' lowering, and
-  /// whose type needs to be promoted.
-  virtual SDOperand CustomPromoteOperation(SDOperand Op, SelectionDAG &DAG);
-  
+  /// CheckTailCallReturnConstraints - Check whether CALL node immediatly
+  /// preceeds the RET node and whether the return uses the result of the node
+  /// or is a void return. This function can be used by the target to determine
+  /// eligiblity of tail call optimization.
+  static bool CheckTailCallReturnConstraints(SDOperand Call, SDOperand Ret) {
+    unsigned NumOps = Ret.getNumOperands();
+    if ((NumOps == 1 &&
+       (Ret.getOperand(0) == SDOperand(Call.Val,1) ||
+        Ret.getOperand(0) == SDOperand(Call.Val,0))) ||
+      (NumOps > 1 &&
+       Ret.getOperand(0) == SDOperand(Call.Val,Call.Val->getNumValues()-1) &&
+       Ret.getOperand(1) == SDOperand(Call.Val,0)))
+      return true;
+    return false;
+  }
+
+  /// GetPossiblePreceedingTailCall - Get preceeding TailCallNodeOpCode node if
+  /// it exists skip possible ISD:TokenFactor.
+  static SDOperand GetPossiblePreceedingTailCall(SDOperand Chain,
+                                                 unsigned TailCallNodeOpCode) {
+    if (Chain.getOpcode() == TailCallNodeOpCode) {
+      return Chain;
+    } else if (Chain.getOpcode() == ISD::TokenFactor) {
+      if (Chain.getNumOperands() &&
+          Chain.getOperand(0).getOpcode() == TailCallNodeOpCode)
+        return Chain.getOperand(0);
+    }
+    return Chain;
+  }
+
   /// getTargetNodeName() - This method returns the name of a target specific
   /// DAG node.
   virtual const char *getTargetNodeName(unsigned Opcode) const;
@@ -1069,78 +1139,24 @@
     Value *CallOperandVal;
   
     /// ConstraintVT - The ValueType for the operand value.
-    MVT::ValueType ConstraintVT;
+    MVT ConstraintVT;
   
     AsmOperandInfo(const InlineAsm::ConstraintInfo &info)
       : InlineAsm::ConstraintInfo(info), 
         ConstraintType(TargetLowering::C_Unknown),
         CallOperandVal(0), ConstraintVT(MVT::Other) {
     }
-  
-    /// getConstraintGenerality - Return an integer indicating how general CT is.
-    unsigned getConstraintGenerality(TargetLowering::ConstraintType CT) {
-      switch (CT) {
-      default: assert(0 && "Unknown constraint type!");
-      case TargetLowering::C_Other:
-      case TargetLowering::C_Unknown:
-        return 0;
-      case TargetLowering::C_Register:
-        return 1;
-      case TargetLowering::C_RegisterClass:
-        return 2;
-      case TargetLowering::C_Memory:
-        return 3;
-      }
-    }
-
-    /// ComputeConstraintToUse - Determines the constraint code and constraint
-    /// type to use.
-    void ComputeConstraintToUse(const TargetLowering &TLI) {
-      assert(!Codes.empty() && "Must have at least one constraint");
-  
-      std::string *Current = &Codes[0];
-      TargetLowering::ConstraintType CurType = TLI.getConstraintType(*Current);
-      if (Codes.size() == 1) {   // Single-letter constraints ('r') are very common.
-        ConstraintCode = *Current;
-        ConstraintType = CurType;
-      } else {
-        unsigned CurGenerality = getConstraintGenerality(CurType);
-
-        // If we have multiple constraints, try to pick the most general one ahead
-        // of time.  This isn't a wonderful solution, but handles common cases.
-        for (unsigned j = 1, e = Codes.size(); j != e; ++j) {
-          TargetLowering::ConstraintType ThisType = TLI.getConstraintType(Codes[j]);
-          unsigned ThisGenerality = getConstraintGenerality(ThisType);
-          if (ThisGenerality > CurGenerality) {
-            // This constraint letter is more general than the previous one,
-            // use it.
-            CurType = ThisType;
-            Current = &Codes[j];
-            CurGenerality = ThisGenerality;
-          }
-        }
-
-        ConstraintCode = *Current;
-        ConstraintType = CurType;
-      }
-
-      if (ConstraintCode == "X" && CallOperandVal) {
-        if (isa<BasicBlock>(CallOperandVal) || isa<ConstantInt>(CallOperandVal))
-          return;
-        // This matches anything.  Labels and constants we handle elsewhere 
-        // ('X' is the only thing that matches labels).  Otherwise, try to 
-        // resolve it to something we know about by looking at the actual 
-        // operand type.
-        std::string s = "";
-        TLI.lowerXConstraint(ConstraintVT, s);
-        if (s!="") {
-          ConstraintCode = s;
-          ConstraintType = TLI.getConstraintType(ConstraintCode);
-        }
-      }
-    }
   };
 
+  /// ComputeConstraintToUse - Determines the constraint code and constraint
+  /// type to use for the specific AsmOperandInfo, setting
+  /// OpInfo.ConstraintCode and OpInfo.ConstraintType.  If the actual operand
+  /// being passed in is available, it can be passed in as Op, otherwise an
+  /// empty SDOperand can be passed.
+  virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo,
+                                      SDOperand Op,
+                                      SelectionDAG *DAG = 0) const;
+  
   /// getConstraintType - Given a constraint, return the type of constraint it
   /// is for this target.
   virtual ConstraintType getConstraintType(const std::string &Constraint) const;
@@ -1150,7 +1166,7 @@
   /// This should only be used for C_RegisterClass constraints.
   virtual std::vector<unsigned> 
   getRegClassForInlineAsmConstraint(const std::string &Constraint,
-                                    MVT::ValueType VT) const;
+                                    MVT VT) const;
 
   /// getRegForInlineAsmConstraint - Given a physical register constraint (e.g.
   /// {edx}), return the register number and the register class for the
@@ -1164,19 +1180,19 @@
   /// this returns a register number of 0 and a null register class pointer..
   virtual std::pair<unsigned, const TargetRegisterClass*> 
     getRegForInlineAsmConstraint(const std::string &Constraint,
-                                 MVT::ValueType VT) const;
+                                 MVT VT) const;
   
   /// LowerXConstraint - try to replace an X constraint, which matches anything,
   /// with another that has more specific requirements based on the type of the
-  /// corresponding operand.
-  virtual void lowerXConstraint(MVT::ValueType ConstraintVT, 
-                                std::string&) const;
+  /// corresponding operand.  This returns null if there is no replacement to
+  /// make.
+  virtual const char *LowerXConstraint(MVT ConstraintVT) const;
   
   /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
   /// vector.  If it is invalid, don't add anything to Ops.
   virtual void LowerAsmOperandForConstraint(SDOperand Op, char ConstraintLetter,
                                             std::vector<SDOperand> &Ops,
-                                            SelectionDAG &DAG);
+                                            SelectionDAG &DAG) const;
   
   //===--------------------------------------------------------------------===//
   // Scheduler hooks
@@ -1188,7 +1204,7 @@
   // insert.  The specified MachineInstr is created but not inserted into any
   // basic blocks, and the scheduler passes ownership of it to this method.
   virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
-                                                         MachineBasicBlock *MBB);
+                                                        MachineBasicBlock *MBB);
 
   //===--------------------------------------------------------------------===//
   // Addressing mode description hooks (used by LSR etc).
@@ -1222,7 +1238,7 @@
     return false;
   }
 
-  virtual bool isTruncateFree(MVT::ValueType VT1, MVT::ValueType VT2) const {
+  virtual bool isTruncateFree(MVT VT1, MVT VT2) const {
     return false;
   }
   
@@ -1267,24 +1283,18 @@
   TargetMachine &TM;
   const TargetData *TD;
 
-  /// IsLittleEndian - True if this is a little endian target.
+  /// PointerTy - The type to use for pointers, usually i32 or i64.
   ///
-  bool IsLittleEndian;
+  MVT PointerTy;
 
-  /// PointerTy - The type to use for pointers, usually i32 or i64.
+  /// IsLittleEndian - True if this is a little endian target.
   ///
-  MVT::ValueType PointerTy;
+  bool IsLittleEndian;
 
   /// UsesGlobalOffsetTable - True if this target uses a GOT for PIC codegen.
   ///
   bool UsesGlobalOffsetTable;
   
-  /// ShiftAmountTy - The type to use for shift amounts, usually i8 or whatever
-  /// PointerTy is.
-  MVT::ValueType ShiftAmountTy;
-
-  OutOfRangeShiftAmount ShiftAmtHandling;
-
   /// SelectIsExpensive - Tells the code generator not to expand operations
   /// into sequences that use the select operations if possible.
   bool SelectIsExpensive;
@@ -1300,14 +1310,6 @@
   /// it.
   bool Pow2DivIsCheap;
   
-  /// SetCCResultContents - Information about the contents of the high-bits in
-  /// the result of a setcc comparison operation.
-  SetCCResultValue SetCCResultContents;
-
-  /// SchedPreferenceInfo - The target scheduling preference: shortest possible
-  /// total cycles or lowest register usage.
-  SchedPreference SchedPreferenceInfo;
-  
   /// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement
   /// llvm.setjmp.  Defaults to false.
   bool UseUnderscoreSetJmp;
@@ -1316,6 +1318,20 @@
   /// llvm.longjmp.  Defaults to false.
   bool UseUnderscoreLongJmp;
 
+  /// ShiftAmountTy - The type to use for shift amounts, usually i8 or whatever
+  /// PointerTy is.
+  MVT ShiftAmountTy;
+
+  OutOfRangeShiftAmount ShiftAmtHandling;
+
+  /// SetCCResultContents - Information about the contents of the high-bits in
+  /// the result of a setcc comparison operation.
+  SetCCResultValue SetCCResultContents;
+
+  /// SchedPreferenceInfo - The target scheduling preference: shortest possible
+  /// total cycles or lowest register usage.
+  SchedPreference SchedPreferenceInfo;
+  
   /// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers
   unsigned JumpBufSize;
   
@@ -1354,21 +1370,24 @@
   /// each ValueType the target supports natively.
   TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE];
   unsigned char NumRegistersForVT[MVT::LAST_VALUETYPE];
-  MVT::ValueType RegisterTypeForVT[MVT::LAST_VALUETYPE];
+  MVT RegisterTypeForVT[MVT::LAST_VALUETYPE];
 
   /// TransformToType - For any value types we are promoting or expanding, this
   /// contains the value type that we are changing to.  For Expanded types, this
   /// contains one step of the expand (e.g. i64 -> i32), even if there are
   /// multiple steps required (e.g. i64 -> i16).  For types natively supported
   /// by the system, this holds the same type (e.g. i32 -> i32).
-  MVT::ValueType TransformToType[MVT::LAST_VALUETYPE];
+  MVT TransformToType[MVT::LAST_VALUETYPE];
+
+  // Defines the capacity of the TargetLowering::OpActions table
+  static const int OpActionsCapacity = 176;
 
   /// OpActions - For each operation and each value type, keep a LegalizeAction
   /// that indicates how instruction selection should deal with the operation.
   /// Most operations are Legal (aka, supported natively by the target), but
   /// operations that are not should be described.  Note that operations on
   /// non-legal value types are not described here.
-  uint64_t OpActions[156];
+  uint64_t OpActions[OpActionsCapacity];
   
   /// LoadXActions - For each load of load extension type and each value type,
   /// keep a LegalizeAction that indicates how instruction selection should deal
@@ -1395,13 +1414,13 @@
 
   std::vector<APFloat> LegalFPImmediates;
 
-  std::vector<std::pair<MVT::ValueType,
-                        TargetRegisterClass*> > AvailableRegClasses;
+  std::vector<std::pair<MVT, TargetRegisterClass*> > AvailableRegClasses;
 
   /// TargetDAGCombineArray - Targets can specify ISD nodes that they would
   /// like PerformDAGCombine callbacks for by calling setTargetDAGCombine(),
   /// which sets a bit in this array.
-  unsigned char TargetDAGCombineArray[160/(sizeof(unsigned char)*8)];
+  unsigned char
+  TargetDAGCombineArray[OpActionsCapacity/(sizeof(unsigned char)*8)];
   
   /// PromoteToType - For operations that must be promoted to a specific type,
   /// this holds the destination type.  This map should be sparse, so don't hold
@@ -1409,7 +1428,8 @@
   ///
   /// Targets add entries to this map with AddPromotedToType(..), clients access
   /// this with getTypeToPromoteTo(..).
-  std::map<std::pair<unsigned, MVT::ValueType>, MVT::ValueType> PromoteToType;
+  std::map<std::pair<unsigned, MVT::SimpleValueType>, MVT::SimpleValueType>
+    PromoteToType;
 
   /// LibcallRoutineNames - Stores the name each libcall.
   ///
@@ -1420,7 +1440,7 @@
   ISD::CondCode CmpLibcallCCs[RTLIB::UNKNOWN_LIBCALL];
 
 protected:
-  /// When lowering %llvm.memset this field specifies the maximum number of
+  /// When lowering @llvm.memset this field specifies the maximum number of
   /// store operations that may be substituted for the call to memset. Targets
   /// must set this value based on the cost threshold for that target. Targets
   /// should assume that the memset will be done using as many of the largest
@@ -1431,7 +1451,7 @@
   /// @brief Specify maximum number of store instructions per memset call.
   unsigned maxStoresPerMemset;
 
-  /// When lowering %llvm.memcpy this field specifies the maximum number of
+  /// When lowering @llvm.memcpy this field specifies the maximum number of
   /// store operations that may be substituted for a call to memcpy. Targets
   /// must set this value based on the cost threshold for that target. Targets
   /// should assume that the memcpy will be done using as many of the largest
@@ -1443,7 +1463,7 @@
   /// @brief Specify maximum bytes of store instructions per memcpy call.
   unsigned maxStoresPerMemcpy;
 
-  /// When lowering %llvm.memmove this field specifies the maximum number of
+  /// When lowering @llvm.memmove this field specifies the maximum number of
   /// store instructions that may be substituted for a call to memmove. Targets
   /// must set this value based on the cost threshold for that target. Targets
   /// should assume that the memmove will be done using as many of the largest

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetMachine.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetMachine.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetMachine.h Sun Jul  6 15:45:41 2008
@@ -16,7 +16,7 @@
 
 #include "llvm/Target/TargetInstrItineraries.h"
 #include <cassert>
-#include <string>
+#include <iosfwd>
 
 namespace llvm {
 
@@ -99,7 +99,7 @@
   /// used by the LLC tool to determine which target to use when an explicit
   /// -march option is not specified.  If a target returns zero, it will never
   /// be chosen without an explicit -march option.
-  static unsigned getModuleMatchQuality(const Module &M) { return 0; }
+  static unsigned getModuleMatchQuality(const Module &) { return 0; }
 
   /// getJITMatchQuality - This static method should be implemented by targets
   /// that provide JIT capabilities to indicate how suitable they are for
@@ -195,10 +195,10 @@
   /// This method should return FileModel::Error if emission of this file type
   /// is not supported.
   ///
-  virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
-                                               std::ostream &Out,
-                                               CodeGenFileType FileType,
-                                               bool Fast) {
+  virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
+                                               std::ostream &,
+                                               CodeGenFileType,
+                                               bool /*Fast*/) {
     return FileModel::None;
   }
 
@@ -206,8 +206,8 @@
   /// to be split up (e.g., to add an object writer pass), this method can be
   /// used to finish up adding passes to emit the file, if necessary.
   ///
-  virtual bool addPassesToEmitFileFinish(PassManagerBase &PM,
-                                         MachineCodeEmitter *MCE, bool Fast) {
+  virtual bool addPassesToEmitFileFinish(PassManagerBase &,
+                                         MachineCodeEmitter *, bool /*Fast*/) {
     return true;
   }
  
@@ -217,8 +217,9 @@
   /// of functions.  This method returns true if machine code emission is
   /// not supported.
   ///
-  virtual bool addPassesToEmitMachineCode(PassManagerBase &PM,
-                                          MachineCodeEmitter &MCE, bool Fast) {
+  virtual bool addPassesToEmitMachineCode(PassManagerBase &,
+                                          MachineCodeEmitter &,
+                                          bool /*Fast*/) {
     return true;
   }
 
@@ -226,8 +227,8 @@
   /// require having the entire module at once.  This is not recommended, do not
   /// use this.
   virtual bool WantsWholeFile() const { return false; }
-  virtual bool addPassesToEmitWholeFile(PassManager &PM, std::ostream &Out,
-                                        CodeGenFileType FileType, bool Fast) {
+  virtual bool addPassesToEmitWholeFile(PassManager &, std::ostream &,
+                                        CodeGenFileType, bool /*Fast*/) {
     return true;
   }
 };
@@ -277,22 +278,29 @@
   /// addInstSelector - This method should add any "last minute" LLVM->LLVM
   /// passes, then install an instruction selector pass, which converts from
   /// LLVM code to machine instructions.
-  virtual bool addInstSelector(PassManagerBase &PM, bool Fast) {
+  virtual bool addInstSelector(PassManagerBase &, bool /*Fast*/) {
     return true;
   }
-  
+
+  /// addPreRegAllocPasses - This method may be implemented by targets that want
+  /// to run passes immediately before register allocation. This should return
+  /// true if -print-machineinstrs should print after these passes.
+  virtual bool addPreRegAlloc(PassManagerBase &, bool /*Fast*/) {
+    return false;
+  }
+
   /// addPostRegAllocPasses - This method may be implemented by targets that
   /// want to run passes after register allocation but before prolog-epilog
   /// insertion.  This should return true if -print-machineinstrs should print
   /// after these passes.
-  virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast) {
+  virtual bool addPostRegAlloc(PassManagerBase &, bool /*Fast*/) {
     return false;
   }
   
   /// addPreEmitPass - This pass may be implemented by targets that want to run
   /// passes immediately before machine code is emitted.  This should return
   /// true if -print-machineinstrs should print out the code after the passes.
-  virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast) {
+  virtual bool addPreEmitPass(PassManagerBase &, bool /*Fast*/) {
     return false;
   }
   
@@ -300,16 +308,16 @@
   /// addAssemblyEmitter - This pass should be overridden by the target to add
   /// the asmprinter, if asm emission is supported.  If this is not supported,
   /// 'true' should be returned.
-  virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, 
-                                  std::ostream &Out) {
+  virtual bool addAssemblyEmitter(PassManagerBase &, bool /*Fast*/, 
+                                  std::ostream &) {
     return true;
   }
   
   /// addCodeEmitter - This pass should be overridden by the target to add a
   /// code emitter, if supported.  If this is not supported, 'true' should be
   /// returned. If DumpAsm is true, the generated assembly is printed to cerr.
-  virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast, bool DumpAsm,
-                              MachineCodeEmitter &MCE) {
+  virtual bool addCodeEmitter(PassManagerBase &, bool /*Fast*/,
+                              bool /*DumpAsm*/, MachineCodeEmitter &) {
     return true;
   }
 
@@ -317,8 +325,8 @@
   /// a code emitter (without setting flags), if supported.  If this is not
   /// supported, 'true' should be returned.  If DumpAsm is true, the generated
   /// assembly is printed to cerr.
-  virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast, 
-                                    bool DumpAsm, MachineCodeEmitter &MCE) {
+  virtual bool addSimpleCodeEmitter(PassManagerBase &, bool /*Fast*/,
+                                    bool /*DumpAsm*/, MachineCodeEmitter &) {
     return true;
   }
 

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetOptions.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetOptions.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetOptions.h Sun Jul  6 15:45:41 2008
@@ -86,6 +86,17 @@
   /// OptimizeForSize - When this flag is set, the code generator avoids 
   /// optimizations that increase size.
   extern bool OptimizeForSize;
+
+  /// StackAlignment - Override default stack alignment for target.
+  extern unsigned StackAlignment;
+
+  /// RealignStack - This flag indicates, whether stack should be automatically
+  /// realigned, if needed.
+  extern bool RealignStack;
+
+  /// VerboseAsm - When this flag is set, the asm printer prints additional
+  /// comments to asm directives.
+  extern bool VerboseAsm;
 } // End llvm namespace
 
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/Target/TargetRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Target/TargetRegisterInfo.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Target/TargetRegisterInfo.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Target/TargetRegisterInfo.h Sun Jul  6 15:45:41 2008
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/ValueTypes.h"
 #include <cassert>
 #include <functional>
+#include <set>
 
 namespace llvm {
 
@@ -41,18 +42,15 @@
 /// Registers that this does not apply to simply should set this to null.
 /// The SubRegs field is a zero terminated array of registers that are
 /// sub-registers of the specific register, e.g. AL, AH are sub-registers of AX.
-/// The ImmsubRegs field is a subset of SubRegs. It includes only the immediate
-/// sub-registers. e.g. EAX has only one immediate sub-register of AX, not AH,
-/// AL which are immediate sub-registers of AX. The SuperRegs field is a zero
-/// terminated array of registers that are super-registers of the specific
-/// register, e.g. RAX, EAX, are super-registers of AX.
+/// The SuperRegs field is a zero terminated array of registers that are
+/// super-registers of the specific register, e.g. RAX, EAX, are super-registers
+/// of AX.
 ///
 struct TargetRegisterDesc {
   const char     *AsmName;      // Assembly language name for the register
   const char     *Name;         // Printable name for the reg (for debugging)
   const unsigned *AliasSet;     // Register Alias Set, described above
   const unsigned *SubRegs;      // Sub-register set, described above
-  const unsigned *ImmSubRegs;   // Immediate sub-register set, described above
   const unsigned *SuperRegs;    // Super-register set, described above
 };
 
@@ -61,7 +59,7 @@
   typedef const unsigned* iterator;
   typedef const unsigned* const_iterator;
 
-  typedef const MVT::ValueType* vt_iterator;
+  typedef const MVT* vt_iterator;
   typedef const TargetRegisterClass* const * sc_iterator;
 private:
   unsigned ID;
@@ -76,7 +74,7 @@
   const iterator RegsBegin, RegsEnd;
 public:
   TargetRegisterClass(unsigned id,
-                      const MVT::ValueType *vts,
+                      const MVT *vts,
                       const TargetRegisterClass * const *subcs,
                       const TargetRegisterClass * const *supcs,
                       const TargetRegisterClass * const *subregcs,
@@ -99,7 +97,7 @@
 
   /// getNumRegs - Return the number of registers in this class.
   ///
-  unsigned getNumRegs() const { return RegsEnd-RegsBegin; }
+  unsigned getNumRegs() const { return (unsigned)(RegsEnd-RegsBegin); }
 
   /// getRegister - Return the specified register in the class.
   ///
@@ -118,7 +116,7 @@
 
   /// hasType - return true if this TargetRegisterClass has the ValueType vt.
   ///
-  bool hasType(MVT::ValueType vt) const {
+  bool hasType(MVT vt) const {
     for(int i = 0; VTs[i] != MVT::Other; ++i)
       if (VTs[i] == vt)
         return true;
@@ -276,6 +274,9 @@
 /// descriptor.
 ///
 class TargetRegisterInfo {
+protected:
+  const unsigned* SubregHash;
+  const unsigned SubregHashSize;
 public:
   typedef const TargetRegisterClass * const * regclass_iterator;
 private:
@@ -290,7 +291,9 @@
                      regclass_iterator RegClassBegin,
                      regclass_iterator RegClassEnd,
                      int CallFrameSetupOpcode = -1,
-                     int CallFrameDestroyOpcode = -1);
+                     int CallFrameDestroyOpcode = -1,
+                     const unsigned* subregs = 0,
+                     const unsigned subregsize = 0);
   virtual ~TargetRegisterInfo();
 public:
 
@@ -324,7 +327,7 @@
   /// register of the given type. If type is MVT::Other, then just return any
   /// register class the register belongs to.
   const TargetRegisterClass *getPhysicalRegisterRegClass(unsigned Reg,
-                                          MVT::ValueType VT = MVT::Other) const;
+                                          MVT VT = MVT::Other) const;
 
   /// getAllocatableSet - Returns a bitset indexed by register number
   /// indicating if a register is allocatable or not. If a register class is
@@ -362,14 +365,6 @@
     return get(RegNo).SubRegs;
   }
 
-  /// getImmediateSubRegisters - Return the set of registers that are immediate
-  /// sub-registers of the specified register, or a null list of there are none.
-  /// The list returned is zero terminated.
-  ///
-  const unsigned *getImmediateSubRegisters(unsigned RegNo) const {
-    return get(RegNo).ImmSubRegs;
-  }
-
   /// getSuperRegisters - Return the list of registers that are super-registers
   /// of the specified register, or a null list of there are none. The list
   /// returned is zero terminated and sorted according to super-sub register
@@ -419,8 +414,18 @@
   /// isSubRegister - Returns true if regB is a sub-register of regA.
   ///
   bool isSubRegister(unsigned regA, unsigned regB) const {
-    for (const unsigned *SR = getSubRegisters(regA); *SR; ++SR)
-      if (*SR == regB) return true;
+    // SubregHash is a simple quadratically probed hash table.
+    size_t index = (regA + regB * 37) & (SubregHashSize-1);
+    unsigned ProbeAmt = 2;
+    while (SubregHash[index*2] != 0 &&
+           SubregHash[index*2+1] != 0) {
+      if (SubregHash[index*2] == regA && SubregHash[index*2+1] == regB)
+        return true;
+      
+      index = (index + ProbeAmt) & (SubregHashSize-1);
+      ProbeAmt += 2;
+    }
+    
     return false;
   }
 
@@ -465,7 +470,7 @@
   regclass_iterator regclass_end() const { return RegClassEnd; }
 
   unsigned getNumRegClasses() const {
-    return regclass_end()-regclass_begin();
+    return (unsigned)(regclass_end()-regclass_begin());
   }
   
   /// getRegClass - Returns the register class associated with the enumeration
@@ -516,6 +521,13 @@
     return !hasFP(MF);
   }
 
+  // needsStackRealignment - true if storage within the function requires the
+  // stack pointer to be aligned more than the normal calling convention calls
+  // for.
+  virtual bool needsStackRealignment(const MachineFunction &MF) const {
+    return false;
+  }
+
   /// getCallFrameSetup/DestroyOpcode - These methods return the opcode of the
   /// frame setup/destroy instructions if they exist (-1 otherwise).  Some
   /// targets use pseudo instructions in order to abstract away the difference

Modified: llvm/branches/non-call-eh/include/llvm/Transforms/IPO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Transforms/IPO.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Transforms/IPO.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Transforms/IPO.h Sun Jul  6 15:45:41 2008
@@ -102,12 +102,22 @@
 
 //===----------------------------------------------------------------------===//
 /// createInternalizePass - This pass loops over all of the functions in the
-/// input module, looking for a main function.  If a list of symbols is
-/// specified with the -internalize-public-api-* command line options, those
-/// symbols are internalized.  Otherwise if InternalizeEverything is set and
-/// the main function is found, all other globals are marked as internal.
+/// input module, internalizing all globals (functions and variables) not part
+/// of the api.  If a list of symbols is specified with the
+/// -internalize-public-api-* command line options, those symbols are not
+/// internalized and all others are.  Otherwise if AllButMain is set and the
+/// main function is found, all other globals are marked as internal. If no api
+/// is supplied and AllButMain is not set, or no main function is found, nothing
+/// is internalized.
 ///
-ModulePass *createInternalizePass(bool InternalizeEverything);
+ModulePass *createInternalizePass(bool AllButMain);
+
+/// createInternalizePass - This pass loops over all of the functions in the
+/// input module, internalizing all globals (functions and variables) not in the
+/// given exportList.
+///
+/// Note that commandline options that are used with the above function are not
+/// used now! Also, when exportList is empty, nothing is internalized.
 ModulePass *createInternalizePass(const std::vector<const char *> &exportList);
 
 //===----------------------------------------------------------------------===//
@@ -159,11 +169,6 @@
 ///
 ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
 
-/// createOptimizeWellKnownCallsPass - This pass optimizes specific calls to
-/// specific well-known (library) functions.
-ModulePass *createSimplifyLibCallsPass();
-
-
 /// createIndMemRemPass - This pass removes potential indirect calls of
 /// malloc and free
 ModulePass *createIndMemRemPass();

Modified: llvm/branches/non-call-eh/include/llvm/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Transforms/Scalar.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Transforms/Scalar.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Transforms/Scalar.h Sun Jul  6 15:45:41 2008
@@ -15,8 +15,6 @@
 #ifndef LLVM_TRANSFORMS_SCALAR_H
 #define LLVM_TRANSFORMS_SCALAR_H
 
-#include <cstdlib>
-
 namespace llvm {
 
 class FunctionPass;
@@ -162,7 +160,7 @@
 //   ret int %Y
 //
 FunctionPass *createPromoteMemoryToRegisterPass();
-extern const PassInfo *PromoteMemoryToRegisterID;
+extern const PassInfo *const PromoteMemoryToRegisterID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -171,7 +169,7 @@
 // hacking easier.
 //
 FunctionPass *createDemoteRegisterToMemoryPass();
-extern const PassInfo *DemoteRegisterToMemoryID;
+extern const PassInfo *const DemoteRegisterToMemoryID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -204,7 +202,7 @@
 //
 FunctionPass *createJumpThreadingPass();
   
-  //===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
 // simplify terminator instructions, etc...
@@ -223,7 +221,7 @@
 // (set, immediate dominators, tree, and frontier) information.
 //
 FunctionPass *createBreakCriticalEdgesPass();
-extern const PassInfo *BreakCriticalEdgesID;
+extern const PassInfo *const BreakCriticalEdgesID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -234,7 +232,7 @@
 //   AU.addRequiredID(LoopSimplifyID);
 //
 FunctionPass *createLoopSimplifyPass();
-extern const PassInfo *LoopSimplifyID;
+extern const PassInfo *const LoopSimplifyID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -244,7 +242,7 @@
 //   AU.addRequiredID(LowerAllocationsID);
 //
 Pass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false);
-extern const PassInfo *LowerAllocationsID;
+extern const PassInfo *const LowerAllocationsID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -259,7 +257,7 @@
 // chained binary branch instructions.
 //
 FunctionPass *createLowerSwitchPass();
-extern const PassInfo *LowerSwitchID;
+extern const PassInfo *const LowerSwitchID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -271,8 +269,8 @@
 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
 // lowering pass.
 //
-FunctionPass *createLowerInvokePass(const TargetLowering *TLI = NULL);
-extern const PassInfo *LowerInvokePassID;
+FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
+extern const PassInfo *const LowerInvokePassID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -287,7 +285,7 @@
 // optimizations.
 //
 LoopPass *createLCSSAPass();
-extern const PassInfo *LCSSAID;
+extern const PassInfo *const LCSSAID;
 
 //===----------------------------------------------------------------------===//
 //
@@ -319,6 +317,19 @@
 
 //===----------------------------------------------------------------------===//
 //
+// LoopDeletion - This pass performs DCE of non-infinite loops that it
+// can prove are dead.
+//
+LoopPass *createLoopDeletionPass();
+  
+//===----------------------------------------------------------------------===//
+//
+/// createSimplifyLibCallsPass - This pass optimizes specific calls to
+/// specific well-known (library) functions.
+FunctionPass *createSimplifyLibCallsPass();
+
+//===----------------------------------------------------------------------===//
+//
 // CodeGenPrepare - This pass prepares a function for instruction selection.
 //
 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);

Modified: llvm/branches/non-call-eh/include/llvm/Transforms/Utils/BasicBlockUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Transforms/Utils/BasicBlockUtils.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Transforms/Utils/BasicBlockUtils.h Sun Jul  6 15:45:41 2008
@@ -120,6 +120,19 @@
 /// the loop info is updated.
 ///
 BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P);
+ 
+/// SplitBlockPredecessors - This method transforms BB by introducing a new
+/// basic block into the function, and moving some of the predecessors of BB to
+/// be predecessors of the new block.  The new predecessors are indicated by the
+/// Preds array, which has NumPreds elements in it.  The new block is given a
+/// suffix of 'Suffix'.  This function returns the new block.
+///
+/// This currently updates the LLVM IR, AliasAnalysis, DominatorTree and
+/// DominanceFrontier, but no other analyses.
+BasicBlock *SplitBlockPredecessors(BasicBlock *BB, BasicBlock *const *Preds,
+                                   unsigned NumPreds, const char *Suffix,
+                                   Pass *P = 0);
+  
 } // End llvm namespace
 
 #endif

Modified: llvm/branches/non-call-eh/include/llvm/Transforms/Utils/FunctionUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Transforms/Utils/FunctionUtils.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Transforms/Utils/FunctionUtils.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Transforms/Utils/FunctionUtils.h Sun Jul  6 15:45:41 2008
@@ -14,12 +14,12 @@
 #ifndef LLVM_TRANSFORMS_UTILS_FUNCTION_H
 #define LLVM_TRANSFORMS_UTILS_FUNCTION_H
 
-#include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include <vector>
 
 namespace llvm {
   class BasicBlock;
+  class DominatorTree;
   class Function;
 
   /// ExtractCodeRegion - rip out a sequence of basic blocks into a new function

Modified: llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h Sun Jul  6 15:45:41 2008
@@ -40,16 +40,10 @@
   BasicBlock *getUnreachableBlock() const { return UnreachableBlock; }
 
   virtual bool runOnFunction(Function &F);
-  
-  // Force linking the impl of this class into anything that uses this header.
-  static int stub;
 };
 
 Pass *createUnifyFunctionExitNodesPass();
 
-static IncludeFile
-UNIFY_FUNCTION_EXIT_NODES_INCLUDE_FILE(&UnifyFunctionExitNodes::stub);
-
 } // End llvm namespace
 
 #endif

Added: llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnrollLoop.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnrollLoop.h?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnrollLoop.h (added)
+++ llvm/branches/non-call-eh/include/llvm/Transforms/Utils/UnrollLoop.h Sun Jul  6 15:45:41 2008
@@ -0,0 +1,29 @@
+//===- llvm/Transforms/Utils/UnrollLoop.h - Unrolling utilities -*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines some loop unrolling utilities. It does not define any
+// actual pass or policy, but provides a single function to perform loop
+// unrolling.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
+#define LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
+
+#include "llvm/Analysis/LoopInfo.h"
+
+namespace llvm {
+
+class LPPassManager;
+
+bool UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM);
+
+}
+
+#endif

Modified: llvm/branches/non-call-eh/include/llvm/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Type.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Type.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Type.h Sun Jul  6 15:45:41 2008
@@ -16,7 +16,7 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/ADT/GraphTraits.h"
-#include "llvm/ADT/iterator"
+#include "llvm/ADT/iterator.h"
 #include <string>
 #include <vector>
 
@@ -212,13 +212,33 @@
   inline bool isPrimitiveType() const { return ID <= LastPrimitiveTyID; }
   inline bool isDerivedType()   const { return ID >= FirstDerivedTyID; }
 
-  /// isFirstClassType - Return true if the value is holdable in a register.
+  /// isFirstClassType - Return true if the type is "first class", meaning it
+  /// is a valid type for a Value.
   ///
   inline bool isFirstClassType() const {
+    // There are more first-class kinds than non-first-class kinds, so a
+    // negative test is simpler than a positive one.
+    return ID != FunctionTyID && ID != VoidTyID && ID != OpaqueTyID;
+  }
+
+  /// isSingleValueType - Return true if the type is a valid type for a
+  /// virtual register in codegen.  This includes all first-class types
+  /// except struct and array types.
+  ///
+  inline bool isSingleValueType() const {
     return (ID != VoidTyID && ID <= LastPrimitiveTyID) ||
             ID == IntegerTyID || ID == PointerTyID || ID == VectorTyID;
   }
 
+  /// isAggregateType - Return true if the type is an aggregate type. This
+  /// means it is valid as the first operand of an insertvalue or
+  /// extractvalue instruction. This includes struct and array types, but
+  /// does not include vector types.
+  ///
+  inline bool isAggregateType() const {
+    return ID == StructTyID || ID == ArrayTyID;
+  }
+
   /// isSized - Return true if it makes sense to take the size of this type.  To
   /// get the actual size for a particular target, it is reasonable to use the
   /// TargetData subsystem to do this.
@@ -242,6 +262,19 @@
   /// primitive type.
   ///
   unsigned getPrimitiveSizeInBits() const;
+  
+  /// getFPMantissaWidth - Return the width of the mantissa of this type.  This
+  /// is only valid on scalar floating point types.  If the FP type does not
+  /// have a stable mantissa (e.g. ppc long double), this method returns -1.
+  int getFPMantissaWidth() const {
+    assert(isFloatingPoint() && "Not a floating point type!");
+    if (ID == FloatTyID) return 24;
+    if (ID == DoubleTyID) return 53;
+    if (ID == X86_FP80TyID) return 64;
+    if (ID == FP128TyID) return 113;
+    assert(ID == PPC_FP128TyID && "unknown fp type");
+    return -1;
+  }
 
   /// getForwardedType - Return the type that this type has been resolved to if
   /// it has been resolved to anything.  This is used to implement the
@@ -293,7 +326,7 @@
   static const IntegerType *Int1Ty, *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const Type *T) { return true; }
+  static inline bool classof(const Type *) { return true; }
 
   void addRef() const {
     assert(isAbstract() && "Cannot add a reference to a non-abstract type!");

Modified: llvm/branches/non-call-eh/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Use.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Use.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Use.h Sun Jul  6 15:45:41 2008
@@ -17,7 +17,7 @@
 #define LLVM_USE_H
 
 #include "llvm/Support/Casting.h"
-#include "llvm/ADT/iterator"
+#include "llvm/ADT/iterator.h"
 
 namespace llvm {
 
@@ -26,29 +26,80 @@
 
 
 //===----------------------------------------------------------------------===//
+//                          Generic Tagging Functions
+//===----------------------------------------------------------------------===//
+
+/// Tag - generic tag type for (at least 32 bit) pointers
+enum Tag { noTag, tagOne, tagTwo, tagThree };
+
+/// addTag - insert tag bits into an (untagged) pointer
+template <typename T, typename TAG>
+inline T *addTag(const T *P, TAG Tag) {
+    return reinterpret_cast<T*>(ptrdiff_t(P) | Tag);
+}
+
+/// stripTag - remove tag bits from a pointer,
+/// making it dereferencable
+template <ptrdiff_t MASK, typename T>
+inline T *stripTag(const T *P) {
+  return reinterpret_cast<T*>(ptrdiff_t(P) & ~MASK);
+}
+
+/// extractTag - extract tag bits from a pointer
+template <typename TAG, TAG MASK, typename T>
+inline TAG extractTag(const T *P) {
+  return TAG(ptrdiff_t(P) & MASK);
+}
+
+/// transferTag - transfer tag bits from a pointer,
+/// to an untagged pointer
+template <ptrdiff_t MASK, typename T>
+inline T *transferTag(const T *From, const T *To) {
+  return reinterpret_cast<T*>((ptrdiff_t(From) & MASK) | ptrdiff_t(To));
+}
+
+
+//===----------------------------------------------------------------------===//
 //                                  Use Class
 //===----------------------------------------------------------------------===//
 
 // Use is here to make keeping the "use" list of a Value up-to-date really easy.
 //
 class Use {
-public:
+private:
+  /// init - specify Value and User
+  /// @deprecated in 2.4, will be removed soon
   inline void init(Value *V, User *U);
+public:
+  /// swap - provide a fast substitute to std::swap<Use>
+  /// that also works with less standard-compliant compilers
+  void swap(Use &RHS);
+
+private:
+  /// Copy ctor - do not implement
+  Use(const Use &U);
 
-  Use(Value *V, User *U) { init(V, U); }
-  Use(const Use &U) { init(U.Val, U.U); }
+  /// Destructor - Only for zap()
   inline ~Use() {
     if (Val) removeFromList();
   }
 
-  /// Default ctor - This leaves the Use completely unitialized.  The only thing
+  /// Default ctor - This leaves the Use completely uninitialized.  The only thing
   /// that is valid to do with this use is to call the "init" method.
-  inline Use() : Val(0) {}
 
+  inline Use() {}
+  enum PrevPtrTag { zeroDigitTag = noTag
+                  , oneDigitTag = tagOne
+                  , stopTag = tagTwo
+                  , fullStopTag = tagThree };
 
+public:
   operator Value*() const { return Val; }
   Value *get() const { return Val; }
-  User *getUser() const { return U; }
+  User *getUser() const;
+  const Use* getImpliedUser() const;
+  static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0);
+  static void zap(Use *Start, const Use *Stop, bool del = false);
 
   inline void set(Value *Val);
 
@@ -66,19 +117,22 @@
 
   Use *getNext() const { return Next; }
 private:
-  Use *Next, **Prev;
   Value *Val;
-  User *U;
+  Use *Next, **Prev;
 
+  void setPrev(Use **NewPrev) {
+    Prev = transferTag<fullStopTag>(Prev, NewPrev);
+  }
   void addToList(Use **List) {
     Next = *List;
-    if (Next) Next->Prev = &Next;
-    Prev = List;
+    if (Next) Next->setPrev(&Next);
+    setPrev(List);
     *List = this;
   }
   void removeFromList() {
-    *Prev = Next;
-    if (Next) Next->Prev = Prev;
+    Use **StrippedPrev = stripTag<fullStopTag>(Prev);
+    *StrippedPrev = Next;
+    if (Next) Next->setPrev(StrippedPrev);
   }
 
   friend class Value;
@@ -138,7 +192,7 @@
 
   // Retrieve a reference to the current User
   UserTy *operator*() const {
-    assert(U && "Cannot increment end iterator!");
+    assert(U && "Cannot dereference end iterator!");
     return U->getUser();
   }
 

Modified: llvm/branches/non-call-eh/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/User.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/User.h (original)
+++ llvm/branches/non-call-eh/include/llvm/User.h Sun Jul  6 15:45:41 2008
@@ -23,15 +23,38 @@
 
 namespace llvm {
 
+/// OperandTraits - Compile-time customization of
+/// operand-related allocators and accessors
+/// for use of the User class
+template <class>
+struct OperandTraits;
+
+class User;
+
+/// OperandTraits<User> - specialization to User
+template <>
+struct OperandTraits<User> {
+  static inline Use *op_begin(User*);
+  static inline Use *op_end(User*);
+  static inline unsigned operands(const User*);
+  template <class U>
+  struct Layout {
+    typedef U overlay;
+  };
+  static inline void *allocate(unsigned);
+};
+
 class User : public Value {
   User(const User &);             // Do not implement
   void *operator new(size_t);     // Do not implement
+  template <unsigned>
+  friend struct HungoffOperandTraits;
 protected:
   /// OperandList - This is a pointer to the array of Users for this operand.
   /// For nodes of fixed arity (e.g. a binary operator) this array will live
-  /// embedded into the derived class.  For nodes of variable arity
-  /// (e.g. ConstantArrays, CallInst, PHINodes, ReturnInst etc), this memory 
-  /// will be dynamically allocated and should be destroyed by the classes 
+  /// prefixed to the derived class.  For nodes of resizable variable arity
+  /// (e.g. PHINodes, SwitchInst etc.), this memory will be dynamically
+  /// allocated and should be destroyed by the classes' 
   /// virtual dtor.
   Use *OperandList;
 
@@ -39,13 +62,33 @@
   ///
   unsigned NumOperands;
 
-  void *operator new(size_t s, unsigned) {
-    return ::operator new(s);
+  void *operator new(size_t s, unsigned Us);
+  User(const Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
+    : Value(ty, vty), OperandList(OpList), NumOperands(NumOps) {}
+  Use *allocHungoffUses(unsigned) const;
+  void dropHungoffUses(Use *U) {
+    if (OperandList == U) {
+      OperandList = 0;
+      NumOperands = 0;
+    }
+    Use::zap(U, U->getImpliedUser(), true);
   }
-  User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
-    : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
-
 public:
+  ~User() {
+    Use::zap(OperandList, OperandList + NumOperands);
+  }
+  /// operator delete - free memory allocated for User and Use objects
+  void operator delete(void *Usr);
+  /// placement delete - required by std, but never called.
+  void operator delete(void*, unsigned) {
+    assert(0 && "Constructor throws?");
+  }
+  template <unsigned Idx> Use &Op() {
+    return OperandTraits<User>::op_begin(this)[Idx];
+  }
+  template <unsigned Idx> const Use &Op() const {
+    return OperandTraits<User>::op_begin(const_cast<User*>(this))[Idx];
+  }
   Value *getOperand(unsigned i) const {
     assert(i < NumOperands && "getOperand() out of range!");
     return OperandList[i];
@@ -70,15 +113,14 @@
   // dropAllReferences() - This function is in charge of "letting go" of all
   // objects that this User refers to.  This allows one to
   // 'delete' a whole class at a time, even though there may be circular
-  // references... first all references are dropped, and all use counts go to
-  // zero.  Then everything is delete'd for real.  Note that no operations are
+  // references...  First all references are dropped, and all use counts go to
+  // zero.  Then everything is deleted for real.  Note that no operations are
   // valid on an object that has "dropped all references", except operator
   // delete.
   //
   void dropAllReferences() {
-    Use *OL = OperandList;
-    for (unsigned i = 0, e = NumOperands; i != e; ++i)
-      OL[i].set(0);
+    for (op_iterator i = op_begin(), e = op_end(); i != e; ++i)
+      i->set(0);
   }
 
   /// replaceUsesOfWith - Replaces all references to the "From" definition with
@@ -93,6 +135,18 @@
   }
 };
 
+inline Use *OperandTraits<User>::op_begin(User *U) {
+  return U->op_begin();
+}
+
+inline Use *OperandTraits<User>::op_end(User *U) {
+  return U->op_end();
+}
+
+inline unsigned OperandTraits<User>::operands(const User *U) {
+  return U->getNumOperands();
+}
+
 template<> struct simplify_type<User::op_iterator> {
   typedef Value* SimpleType;
 

Modified: llvm/branches/non-call-eh/include/llvm/Value.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/Value.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/Value.h (original)
+++ llvm/branches/non-call-eh/include/llvm/Value.h Sun Jul  6 15:45:41 2008
@@ -8,7 +8,6 @@
 //===----------------------------------------------------------------------===//
 //
 // This file declares the Value class. 
-// This file also defines the Use<> template for users of value.
 //
 //===----------------------------------------------------------------------===//
 
@@ -18,7 +17,7 @@
 #include "llvm/AbstractTypeUser.h"
 #include "llvm/Use.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/Streams.h"
+#include <iosfwd>
 #include <string>
 
 namespace llvm {
@@ -94,6 +93,12 @@
   /// Note that names can have null characters within the string as well as at
   /// their end.  This always returns a non-null pointer.
   const char *getNameStart() const;
+  /// getNameEnd - Return a pointer to the end of the name.
+  const char *getNameEnd() const { return getNameStart() + getNameLen(); }
+  
+  /// isName - Return true if this value has the name specified by the provided
+  /// nul terminated string.
+  bool isName(const char *N) const;
   
   /// getNameLen - Return the length of the string, correctly handling nul
   /// characters embedded into them.
@@ -158,6 +163,8 @@
   ///
   bool hasNUsesOrMore(unsigned N) const;
 
+  bool isUsedInBasicBlock(BasicBlock *BB) const;
+
   /// getNumUses - This method computes the number of uses of this Value.  This
   /// is a linear time operation.  Use hasOneUse, hasNUses, or hasMoreThanNUses
   /// to check for specific values.
@@ -216,6 +223,14 @@
   /// getRawType - This should only be used to implement the vmcore library.
   ///
   const Type *getRawType() const { return Ty.getRawType(); }
+
+  /// stripPointerCasts - This method strips off any unneeded pointer
+  /// casts from the specified value, returning the original uncasted value.
+  /// Note that the returned value is guaranteed to have pointer type.
+  Value *stripPointerCasts();
+  const Value *stripPointerCasts() const {
+    return const_cast<Value*>(this)->stripPointerCasts();
+  }
 };
 
 inline std::ostream &operator<<(std::ostream &OS, const Value &V) {
@@ -223,10 +238,9 @@
   return OS;
 }
 
-void Use::init(Value *v, User *user) {
-  Val = v;
-  U = user;
-  if (Val) Val->addUse(*this);
+void Use::init(Value *V, User *) {
+  Val = V;
+  if (V) V->addUse(*this);
 }
 
 void Use::set(Value *V) {

Modified: llvm/branches/non-call-eh/include/llvm/ValueSymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/include/llvm/ValueSymbolTable.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/include/llvm/ValueSymbolTable.h (original)
+++ llvm/branches/non-call-eh/include/llvm/ValueSymbolTable.h Sun Jul  6 15:45:41 2008
@@ -67,6 +67,7 @@
   /// @returns the value associated with the \p name
   /// @brief Lookup a named Value.
   Value *lookup(const std::string &name) const;
+  Value *lookup(const char *NameBegin, const char *NameEnd) const;
 
   /// @returns true iff the symbol table is empty
   /// @brief Determine if the symbol table is empty
@@ -75,12 +76,6 @@
   /// @brief The number of name/type pairs is returned.
   inline unsigned size() const { return unsigned(vmap.size()); }
 
-  /// Given a base name, return a string that is either equal to it or
-  /// derived from it that does not already occur in the symbol table
-  /// for the specified type.
-  /// @brief Get a name unique to this symbol table
-  std::string getUniqueName(const std::string &BaseName) const;
-
   /// This function can be used from the debugger to display the
   /// content of the symbol table while debugging.
   /// @brief Print out symbol table on stderr

Modified: llvm/branches/non-call-eh/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/AliasAnalysis.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/AliasAnalysis.cpp Sun Jul  6 15:45:41 2008
@@ -34,9 +34,7 @@
 using namespace llvm;
 
 // Register the AliasAnalysis interface, providing a nice name to refer to.
-namespace {
-  RegisterAnalysisGroup<AliasAnalysis> Z("Alias Analysis");
-}
+static RegisterAnalysisGroup<AliasAnalysis> Z("Alias Analysis");
 char AliasAnalysis::ID = 0;
 
 //===----------------------------------------------------------------------===//
@@ -165,7 +163,7 @@
 //
 AliasAnalysis::~AliasAnalysis() {}
 
-/// setTargetData - Subclasses must call this method to initialize the
+/// InitializeAliasAnalysis - Subclasses must call this method to initialize the
 /// AliasAnalysis interface before any other methods are called.
 ///
 void AliasAnalysis::InitializeAliasAnalysis(Pass *P) {

Modified: llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisCounter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisCounter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisCounter.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisCounter.cpp Sun Jul  6 15:45:41 2008
@@ -21,12 +21,12 @@
 #include "llvm/Support/Streams.h"
 using namespace llvm;
 
-namespace {
-  cl::opt<bool>
-  PrintAll("count-aa-print-all-queries", cl::ReallyHidden);
-  cl::opt<bool>
-  PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden);
+static cl::opt<bool>
+PrintAll("count-aa-print-all-queries", cl::ReallyHidden);
+static cl::opt<bool>
+PrintAllFailures("count-aa-print-all-failed-queries", cl::ReallyHidden);
 
+namespace {
   class VISIBILITY_HIDDEN AliasAnalysisCounter 
       : public ModulePass, public AliasAnalysis {
     unsigned No, May, Must;
@@ -113,13 +113,13 @@
       return AliasAnalysis::getModRefInfo(CS1,CS2);
     }
   };
-
-  char AliasAnalysisCounter::ID = 0;
-  RegisterPass<AliasAnalysisCounter>
-  X("count-aa", "Count Alias Analysis Query Responses", false, true);
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
 }
 
+char AliasAnalysisCounter::ID = 0;
+static RegisterPass<AliasAnalysisCounter>
+X("count-aa", "Count Alias Analysis Query Responses", false, true);
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+
 ModulePass *llvm::createAliasAnalysisCounterPass() {
   return new AliasAnalysisCounter();
 }

Modified: llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisEvaluator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisEvaluator.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisEvaluator.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/AliasAnalysisEvaluator.cpp Sun Jul  6 15:45:41 2008
@@ -34,18 +34,18 @@
 #include <sstream>
 using namespace llvm;
 
-namespace {
-  cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
+static cl::opt<bool> PrintAll("print-all-alias-modref-info", cl::ReallyHidden);
 
-  cl::opt<bool> PrintNoAlias("print-no-aliases", cl::ReallyHidden);
-  cl::opt<bool> PrintMayAlias("print-may-aliases", cl::ReallyHidden);
-  cl::opt<bool> PrintMustAlias("print-must-aliases", cl::ReallyHidden);
-
-  cl::opt<bool> PrintNoModRef("print-no-modref", cl::ReallyHidden);
-  cl::opt<bool> PrintMod("print-mod", cl::ReallyHidden);
-  cl::opt<bool> PrintRef("print-ref", cl::ReallyHidden);
-  cl::opt<bool> PrintModRef("print-modref", cl::ReallyHidden);
+static cl::opt<bool> PrintNoAlias("print-no-aliases", cl::ReallyHidden);
+static cl::opt<bool> PrintMayAlias("print-may-aliases", cl::ReallyHidden);
+static cl::opt<bool> PrintMustAlias("print-must-aliases", cl::ReallyHidden);
+
+static cl::opt<bool> PrintNoModRef("print-no-modref", cl::ReallyHidden);
+static cl::opt<bool> PrintMod("print-mod", cl::ReallyHidden);
+static cl::opt<bool> PrintRef("print-ref", cl::ReallyHidden);
+static cl::opt<bool> PrintModRef("print-modref", cl::ReallyHidden);
 
+namespace {
   class VISIBILITY_HIDDEN AAEval : public FunctionPass {
     unsigned NoAlias, MayAlias, MustAlias;
     unsigned NoModRef, Mod, Ref, ModRef;
@@ -73,12 +73,12 @@
     bool runOnFunction(Function &F);
     bool doFinalization(Module &M);
   };
-
-  char AAEval::ID = 0;
-  RegisterPass<AAEval>
-  X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true);
 }
 
+char AAEval::ID = 0;
+static RegisterPass<AAEval>
+X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true);
+
 FunctionPass *llvm::createAAEvalPass() { return new AAEval(); }
 
 static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2,

Modified: llvm/branches/non-call-eh/lib/Analysis/AliasDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/AliasDebugger.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/AliasDebugger.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/AliasDebugger.cpp Sun Jul  6 15:45:41 2008
@@ -121,11 +121,12 @@
     }
 
   };
-
-  char AliasDebugger::ID = 0;
-  RegisterPass<AliasDebugger> X("debug-aa", "AA use debugger", false, true);
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
 }
 
+char AliasDebugger::ID = 0;
+static RegisterPass<AliasDebugger>
+X("debug-aa", "AA use debugger", false, true);
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+
 Pass *llvm::createAliasDebugger() { return new AliasDebugger(); }
 

Modified: llvm/branches/non-call-eh/lib/Analysis/AliasSetTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/AliasSetTracker.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/AliasSetTracker.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/AliasSetTracker.cpp Sun Jul  6 15:45:41 2008
@@ -284,11 +284,7 @@
 
 bool AliasSetTracker::add(FreeInst *FI) {
   bool NewPtr;
-  AliasSet &AS = addPointer(FI->getOperand(0), ~0,
-                            AliasSet::Mods, NewPtr);
-
-  // Free operations are volatile ops (cannot be moved).
-  AS.setVolatile();
+  addPointer(FI->getOperand(0), ~0, AliasSet::Mods, NewPtr);
   return NewPtr;
 }
 
@@ -517,7 +513,7 @@
 
 void AliasSet::print(std::ostream &OS) const {
   OS << "  AliasSet[" << (void*)this << "," << RefCount << "] ";
-  OS << (AliasTy == MustAlias ? "must" : "may ") << " alias, ";
+  OS << (AliasTy == MustAlias ? "must" : "may") << " alias, ";
   switch (AccessTy) {
   case NoModRef: OS << "No access "; break;
   case Refs    : OS << "Ref       "; break;
@@ -585,6 +581,8 @@
       return false;
     }
   };
-  char AliasSetPrinter::ID = 0;
-  RegisterPass<AliasSetPrinter> X("print-alias-sets", "Alias Set Printer", false, true);
 }
+
+char AliasSetPrinter::ID = 0;
+static RegisterPass<AliasSetPrinter>
+X("print-alias-sets", "Alias Set Printer", false, true);

Modified: llvm/branches/non-call-eh/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/BasicAliasAnalysis.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/BasicAliasAnalysis.cpp Sun Jul  6 15:45:41 2008
@@ -32,6 +32,174 @@
 #include <algorithm>
 using namespace llvm;
 
+//===----------------------------------------------------------------------===//
+// Useful predicates
+//===----------------------------------------------------------------------===//
+
+// Determine if an AllocationInst instruction escapes from the function it is
+// contained in. If it does not escape, there is no way for another function to
+// mod/ref it.  We do this by looking at its uses and determining if the uses
+// can escape (recursively).
+static bool AddressMightEscape(const Value *V) {
+  for (Value::use_const_iterator UI = V->use_begin(), E = V->use_end();
+       UI != E; ++UI) {
+    const Instruction *I = cast<Instruction>(*UI);
+    switch (I->getOpcode()) {
+    case Instruction::Load: 
+      break; //next use.
+    case Instruction::Store:
+      if (I->getOperand(0) == V)
+        return true; // Escapes if the pointer is stored.
+      break; // next use.
+    case Instruction::GetElementPtr:
+      if (AddressMightEscape(I))
+        return true;
+      break; // next use.
+    case Instruction::BitCast:
+      if (AddressMightEscape(I))
+        return true;
+      break; // next use
+    case Instruction::Ret:
+      // If returned, the address will escape to calling functions, but no
+      // callees could modify it.
+      break; // next use
+    case Instruction::Call:
+      // If the call is to a few known safe intrinsics, we know that it does
+      // not escape.
+      // TODO: Eventually just check the 'nocapture' attribute.
+      if (!isa<MemIntrinsic>(I))
+        return true;
+      break;  // next use
+    default:
+      return true;
+    }
+  }
+  return false;
+}
+
+/// getUnderlyingObject - This traverses the use chain to figure out what object
+/// the specified value points to.  If the value points to, or is derived from,
+/// a unique object or an argument, return it.  This returns:
+///    Arguments, GlobalVariables, Functions, Allocas, Mallocs.
+static const Value *getUnderlyingObject(const Value *V) {
+  if (!isa<PointerType>(V->getType())) return V;
+
+  // If we are at some type of object, return it. GlobalValues and Allocations
+  // have unique addresses. 
+  if (isa<GlobalValue>(V) || isa<AllocationInst>(V) || isa<Argument>(V))
+    return V;
+
+  // Traverse through different addressing mechanisms...
+  if (const Instruction *I = dyn_cast<Instruction>(V)) {
+    if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I))
+      return getUnderlyingObject(I->getOperand(0));
+  } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
+    if (CE->getOpcode() == Instruction::BitCast || 
+        CE->getOpcode() == Instruction::GetElementPtr)
+      return getUnderlyingObject(CE->getOperand(0));
+  }
+  return V;
+}
+
+static const User *isGEP(const Value *V) {
+  if (isa<GetElementPtrInst>(V) ||
+      (isa<ConstantExpr>(V) &&
+       cast<ConstantExpr>(V)->getOpcode() == Instruction::GetElementPtr))
+    return cast<User>(V);
+  return 0;
+}
+
+static const Value *GetGEPOperands(const Value *V, 
+                                   SmallVector<Value*, 16> &GEPOps){
+  assert(GEPOps.empty() && "Expect empty list to populate!");
+  GEPOps.insert(GEPOps.end(), cast<User>(V)->op_begin()+1,
+                cast<User>(V)->op_end());
+
+  // Accumulate all of the chained indexes into the operand array
+  V = cast<User>(V)->getOperand(0);
+
+  while (const User *G = isGEP(V)) {
+    if (!isa<Constant>(GEPOps[0]) || isa<GlobalValue>(GEPOps[0]) ||
+        !cast<Constant>(GEPOps[0])->isNullValue())
+      break;  // Don't handle folding arbitrary pointer offsets yet...
+    GEPOps.erase(GEPOps.begin());   // Drop the zero index
+    GEPOps.insert(GEPOps.begin(), G->op_begin()+1, G->op_end());
+    V = G->getOperand(0);
+  }
+  return V;
+}
+
+/// isIdentifiedObject - Return true if this pointer refers to a distinct and
+/// identifiable object.  This returns true for:
+///    Global Variables and Functions
+///    Allocas and Mallocs
+///    ByVal and NoAlias Arguments
+///
+static bool isIdentifiedObject(const Value *V) {
+  if (isa<GlobalValue>(V) || isa<AllocationInst>(V))
+    return true;
+  if (const Argument *A = dyn_cast<Argument>(V))
+    return A->hasNoAliasAttr() || A->hasByValAttr();
+  return false;
+}
+
+/// isKnownNonNull - Return true if we know that the specified value is never
+/// null.
+static bool isKnownNonNull(const Value *V) {
+  // Alloca never returns null, malloc might.
+  if (isa<AllocaInst>(V)) return true;
+  
+  // A byval argument is never null.
+  if (const Argument *A = dyn_cast<Argument>(V))
+    return A->hasByValAttr();
+
+  // Global values are not null unless extern weak.
+  if (const GlobalValue *GV = dyn_cast<GlobalValue>(V))
+    return !GV->hasExternalWeakLinkage();
+  return false;
+}
+
+/// isNonEscapingLocalObject - Return true if the pointer is to a function-local
+/// object that never escapes from the function.
+static bool isNonEscapingLocalObject(const Value *V) {
+  // If this is a local allocation, check to see if it escapes.
+  if (isa<AllocationInst>(V))
+    return !AddressMightEscape(V);
+      
+  // If this is an argument that corresponds to a byval or noalias argument,
+  // it can't escape either.
+  if (const Argument *A = dyn_cast<Argument>(V))
+    if (A->hasByValAttr() || A->hasNoAliasAttr())
+      return !AddressMightEscape(V);
+  return false;
+}
+
+
+/// isObjectSmallerThan - Return true if we can prove that the object specified
+/// by V is smaller than Size.
+static bool isObjectSmallerThan(const Value *V, unsigned Size,
+                                const TargetData &TD) {
+  const Type *AccessTy = 0;
+  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
+    AccessTy = GV->getType()->getElementType();
+  
+  if (const AllocationInst *AI = dyn_cast<AllocationInst>(V))
+    if (!AI->isArrayAllocation())
+      AccessTy = AI->getType()->getElementType();
+
+  if (const Argument *A = dyn_cast<Argument>(V))
+    if (A->hasByValAttr())
+      AccessTy = cast<PointerType>(A->getType())->getElementType();
+  
+  if (AccessTy && AccessTy->isSized())
+    return TD.getABITypeSize(AccessTy) < Size;
+  return false;
+}
+
+//===----------------------------------------------------------------------===//
+// NoAA Pass
+//===----------------------------------------------------------------------===//
+
 namespace {
   /// NoAA - This class implements the -no-aa pass, which always returns "I
   /// don't know" for alias queries.  NoAA is unlike other alias analysis
@@ -79,18 +247,22 @@
     virtual void deleteValue(Value *V) {}
     virtual void copyValue(Value *From, Value *To) {}
   };
+}  // End of anonymous namespace
 
-  // Register this pass...
-  char NoAA::ID = 0;
-  RegisterPass<NoAA>
-  U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true);
+// Register this pass...
+char NoAA::ID = 0;
+static RegisterPass<NoAA>
+U("no-aa", "No Alias Analysis (always returns 'may' alias)", true, true);
 
-  // Declare that we implement the AliasAnalysis interface
-  RegisterAnalysisGroup<AliasAnalysis> V(U);
-}  // End of anonymous namespace
+// Declare that we implement the AliasAnalysis interface
+static RegisterAnalysisGroup<AliasAnalysis> V(U);
 
 ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
 
+//===----------------------------------------------------------------------===//
+// BasicAA Pass
+//===----------------------------------------------------------------------===//
+
 namespace {
   /// BasicAliasAnalysis - This is the default alias analysis implementation.
   /// Because it doesn't chain to a previous alias analysis (like -no-aa), it
@@ -124,118 +296,27 @@
                          const Type *BasePtr2Ty,
                          Value **GEP2Ops, unsigned NumGEP2Ops, unsigned G2Size);
   };
+}  // End of anonymous namespace
 
-  // Register this pass...
-  char BasicAliasAnalysis::ID = 0;
-  RegisterPass<BasicAliasAnalysis>
-  X("basicaa", "Basic Alias Analysis (default AA impl)", false, true);
+// Register this pass...
+char BasicAliasAnalysis::ID = 0;
+static RegisterPass<BasicAliasAnalysis>
+X("basicaa", "Basic Alias Analysis (default AA impl)", false, true);
 
-  // Declare that we implement the AliasAnalysis interface
-  RegisterAnalysisGroup<AliasAnalysis, true> Y(X);
-}  // End of anonymous namespace
+// Declare that we implement the AliasAnalysis interface
+static RegisterAnalysisGroup<AliasAnalysis, true> Y(X);
 
 ImmutablePass *llvm::createBasicAliasAnalysisPass() {
   return new BasicAliasAnalysis();
 }
 
-/// getUnderlyingObject - This traverses the use chain to figure out what object
-/// the specified value points to.  If the value points to, or is derived from,
-/// a unique object or an argument, return it.  This returns:
-///    Arguments, GlobalVariables, Functions, Allocas, Mallocs.
-static const Value *getUnderlyingObject(const Value *V) {
-  if (!isa<PointerType>(V->getType())) return 0;
-
-  // If we are at some type of object, return it. GlobalValues and Allocations
-  // have unique addresses. 
-  if (isa<GlobalValue>(V) || isa<AllocationInst>(V) || isa<Argument>(V))
-    return V;
-
-  // Traverse through different addressing mechanisms...
-  if (const Instruction *I = dyn_cast<Instruction>(V)) {
-    if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I))
-      return getUnderlyingObject(I->getOperand(0));
-  } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
-    if (CE->getOpcode() == Instruction::BitCast || 
-        CE->getOpcode() == Instruction::GetElementPtr)
-      return getUnderlyingObject(CE->getOperand(0));
-  }
-  return 0;
-}
-
-static const User *isGEP(const Value *V) {
-  if (isa<GetElementPtrInst>(V) ||
-      (isa<ConstantExpr>(V) &&
-       cast<ConstantExpr>(V)->getOpcode() == Instruction::GetElementPtr))
-    return cast<User>(V);
-  return 0;
-}
-
-static const Value *GetGEPOperands(const Value *V, 
-                                   SmallVector<Value*, 16> &GEPOps){
-  assert(GEPOps.empty() && "Expect empty list to populate!");
-  GEPOps.insert(GEPOps.end(), cast<User>(V)->op_begin()+1,
-                cast<User>(V)->op_end());
-
-  // Accumulate all of the chained indexes into the operand array
-  V = cast<User>(V)->getOperand(0);
-
-  while (const User *G = isGEP(V)) {
-    if (!isa<Constant>(GEPOps[0]) || isa<GlobalValue>(GEPOps[0]) ||
-        !cast<Constant>(GEPOps[0])->isNullValue())
-      break;  // Don't handle folding arbitrary pointer offsets yet...
-    GEPOps.erase(GEPOps.begin());   // Drop the zero index
-    GEPOps.insert(GEPOps.begin(), G->op_begin()+1, G->op_end());
-    V = G->getOperand(0);
-  }
-  return V;
-}
 
 /// pointsToConstantMemory - Chase pointers until we find a (constant
 /// global) or not.
 bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) {
-  if (const Value *V = getUnderlyingObject(P))
-    if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
-      return GV->isConstant();
-  return false;
-}
-
-// Determine if an AllocationInst instruction escapes from the function it is
-// contained in. If it does not escape, there is no way for another function to
-// mod/ref it.  We do this by looking at its uses and determining if the uses
-// can escape (recursively).
-static bool AddressMightEscape(const Value *V) {
-  for (Value::use_const_iterator UI = V->use_begin(), E = V->use_end();
-       UI != E; ++UI) {
-    const Instruction *I = cast<Instruction>(*UI);
-    switch (I->getOpcode()) {
-    case Instruction::Load: 
-      break; //next use.
-    case Instruction::Store:
-      if (I->getOperand(0) == V)
-        return true; // Escapes if the pointer is stored.
-      break; // next use.
-    case Instruction::GetElementPtr:
-      if (AddressMightEscape(I))
-        return true;
-      break; // next use.
-    case Instruction::BitCast:
-      if (AddressMightEscape(I))
-        return true;
-      break; // next use
-    case Instruction::Ret:
-      // If returned, the address will escape to calling functions, but no
-      // callees could modify it.
-      break; // next use
-    case Instruction::Call:
-      // If the call is to a few known safe intrinsics, we know that it does
-      // not escape
-      if (!isa<MemIntrinsic>(I))
-        return true;
-      break;  // next use
-    default:
-      return true;
-    }
-  }
+  if (const GlobalVariable *GV = 
+        dyn_cast<GlobalVariable>(getUnderlyingObject(P)))
+    return GV->isConstant();
   return false;
 }
 
@@ -248,38 +329,31 @@
 BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
   if (!isa<Constant>(P)) {
     const Value *Object = getUnderlyingObject(P);
-    // Allocations and byval arguments are "new" objects.
-    if (Object &&
-        (isa<AllocationInst>(Object) || isa<Argument>(Object))) {
-      // Okay, the pointer is to a stack allocated (or effectively so, for 
-      // for noalias parameters) object.  If the address of this object doesn't
-      // escape from this function body to a callee, then we know that no
-      // callees can mod/ref it unless they are actually passed it.
-      if (isa<AllocationInst>(Object) ||
-          cast<Argument>(Object)->hasByValAttr() ||
-          cast<Argument>(Object)->hasNoAliasAttr())
-        if (!AddressMightEscape(Object)) {
-          bool passedAsArg = false;
-          for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
-              CI != CE; ++CI)
-            if (isa<PointerType>((*CI)->getType()) &&
-                ( getUnderlyingObject(*CI) == P ||
-                  alias(cast<Value>(CI), ~0UL, P, ~0UL) != NoAlias) )
-              passedAsArg = true;
-          
-          if (!passedAsArg)
-            return NoModRef;
-        }
-
-      // If this is a tail call and P points to a stack location, we know that
-      // the tail call cannot access or modify the local stack.
-      // We cannot exclude byval arguments here; these belong to the caller of
-      // the current function not to the current function, and a tail callee
-      // may reference them.
-      if (isa<AllocaInst>(Object))
-        if (CallInst *CI = dyn_cast<CallInst>(CS.getInstruction()))
-          if (CI->isTailCall())
-            return NoModRef;
+    
+    // If this is a tail call and P points to a stack location, we know that
+    // the tail call cannot access or modify the local stack.
+    // We cannot exclude byval arguments here; these belong to the caller of
+    // the current function not to the current function, and a tail callee
+    // may reference them.
+    if (isa<AllocaInst>(Object))
+      if (CallInst *CI = dyn_cast<CallInst>(CS.getInstruction()))
+        if (CI->isTailCall())
+          return NoModRef;
+    
+    // If the pointer is to a locally allocated object that does not escape,
+    // then the call can not mod/ref the pointer unless the call takes the
+    // argument without capturing it.
+    if (isNonEscapingLocalObject(Object)) {
+      bool passedAsArg = false;
+      // TODO: Eventually only check 'nocapture' arguments.
+      for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
+           CI != CE; ++CI)
+        if (isa<PointerType>((*CI)->getType()) &&
+            alias(cast<Value>(CI), ~0U, P, ~0U) != NoAlias)
+          passedAsArg = true;
+      
+      if (!passedAsArg)
+        return NoModRef;
     }
   }
 
@@ -287,6 +361,7 @@
   return AliasAnalysis::getModRefInfo(CS, P, Size);
 }
 
+
 // alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such
 // as array references.  Note that this function is heavily tail recursive.
 // Hopefully we have a smart C++ compiler.  :)
@@ -319,92 +394,39 @@
   const Value *O1 = getUnderlyingObject(V1);
   const Value *O2 = getUnderlyingObject(V2);
 
-  // Pointing at a discernible object?
-  if (O1) {
-    if (O2) {
-      if (const Argument *O1Arg = dyn_cast<Argument>(O1)) {
-        // Incoming argument cannot alias locally allocated object!
-        if (isa<AllocationInst>(O2)) return NoAlias;
-        
-        // If they are two different objects, and one is a noalias argument
-        // then they do not alias.
-        if (O1 != O2 && O1Arg->hasNoAliasAttr())
-          return NoAlias;
-
-        // Byval arguments can't alias globals or other arguments.
-        if (O1 != O2 && O1Arg->hasByValAttr()) return NoAlias;
-        
-        // Otherwise, nothing is known...
-      } 
-      
-      if (const Argument *O2Arg = dyn_cast<Argument>(O2)) {
-        // Incoming argument cannot alias locally allocated object!
-        if (isa<AllocationInst>(O1)) return NoAlias;
-        
-        // If they are two different objects, and one is a noalias argument
-        // then they do not alias.
-        if (O1 != O2 && O2Arg->hasNoAliasAttr())
-          return NoAlias;
-          
-        // Byval arguments can't alias globals or other arguments.
-        if (O1 != O2 && O2Arg->hasByValAttr()) return NoAlias;
-        
-        // Otherwise, nothing is known...
-      
-      } else if (O1 != O2 && !isa<Argument>(O1)) {
-        // If they are two different objects, and neither is an argument,
-        // we know that we have no alias.
-        return NoAlias;
-      }
-
-      // If they are the same object, they we can look at the indexes.  If they
-      // index off of the object is the same for both pointers, they must alias.
-      // If they are provably different, they must not alias.  Otherwise, we
-      // can't tell anything.
-    }
-
-    // Unique values don't alias null, except non-byval arguments.
-    if (isa<ConstantPointerNull>(V2)) {
-      if (const Argument *O1Arg = dyn_cast<Argument>(O1)) {
-        if (O1Arg->hasByValAttr()) 
-          return NoAlias;
-      } else {
-        return NoAlias;                    
-      }
-    }
-
-    if (isa<GlobalVariable>(O1) ||
-        (isa<AllocationInst>(O1) &&
-         !cast<AllocationInst>(O1)->isArrayAllocation()))
-      if (cast<PointerType>(O1->getType())->getElementType()->isSized()) {
-        // If the size of the other access is larger than the total size of the
-        // global/alloca/malloc, it cannot be accessing the global (it's
-        // undefined to load or store bytes before or after an object).
-        const Type *ElTy = cast<PointerType>(O1->getType())->getElementType();
-        unsigned GlobalSize = getTargetData().getABITypeSize(ElTy);
-        if (GlobalSize < V2Size && V2Size != ~0U)
-          return NoAlias;
-      }
-  }
-
-  if (O2) {
-    if (!isa<Argument>(O2) && isa<ConstantPointerNull>(V1))
-      return NoAlias;                    // Unique values don't alias null
-
-    if (isa<GlobalVariable>(O2) ||
-        (isa<AllocationInst>(O2) &&
-         !cast<AllocationInst>(O2)->isArrayAllocation()))
-      if (cast<PointerType>(O2->getType())->getElementType()->isSized()) {
-        // If the size of the other access is larger than the total size of the
-        // global/alloca/malloc, it cannot be accessing the object (it's
-        // undefined to load or store bytes before or after an object).
-        const Type *ElTy = cast<PointerType>(O2->getType())->getElementType();
-        unsigned GlobalSize = getTargetData().getABITypeSize(ElTy);
-        if (GlobalSize < V1Size && V1Size != ~0U)
-          return NoAlias;
-      }
+  if (O1 != O2) {
+    // If V1/V2 point to two different objects we know that we have no alias.
+    if (isIdentifiedObject(O1) && isIdentifiedObject(O2))
+      return NoAlias;
+  
+    // Incoming argument cannot alias locally allocated object!
+    if ((isa<Argument>(O1) && isa<AllocationInst>(O2)) ||
+        (isa<Argument>(O2) && isa<AllocationInst>(O1)))
+      return NoAlias;
+    
+    // Most objects can't alias null.
+    if ((isa<ConstantPointerNull>(V2) && isKnownNonNull(O1)) ||
+        (isa<ConstantPointerNull>(V1) && isKnownNonNull(O2)))
+      return NoAlias;
   }
-
+  
+  // If the size of one access is larger than the entire object on the other
+  // side, then we know such behavior is undefined and can assume no alias.
+  const TargetData &TD = getTargetData();
+  if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, TD)) ||
+      (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, TD)))
+    return NoAlias;
+  
+  // If one pointer is the result of a call/invoke and the other is a
+  // non-escaping local object, then we know the object couldn't escape to a
+  // point where the call could return it.
+  if ((isa<CallInst>(O1) || isa<InvokeInst>(O1)) &&
+      isNonEscapingLocalObject(O2))
+    return NoAlias;
+  if ((isa<CallInst>(O2) || isa<InvokeInst>(O2)) &&
+      isNonEscapingLocalObject(O1))
+    return NoAlias;
+  
   // If we have two gep instructions with must-alias'ing base pointers, figure
   // out if the indexes to the GEP tell us anything about the derived pointer.
   // Note that we also handle chains of getelementptr instructions as well as
@@ -687,7 +709,7 @@
         if (isa<ConstantInt>(GEP1Ops[i]) && 
             !cast<ConstantInt>(GEP1Ops[i])->isZero()) {
           // Yup, there's a constant in the tail.  Set all variables to
-          // constants in the GEP instruction to make it suiteable for
+          // constants in the GEP instruction to make it suitable for
           // TargetData::getIndexedOffset.
           for (i = 0; i != MaxOperands; ++i)
             if (!isa<ConstantInt>(GEP1Ops[i]))
@@ -702,9 +724,15 @@
           int64_t Offset2 = TD.getIndexedOffset(GEPPointerTy, GEP1Ops,
                                                 MinOperands);
 
+          // Make sure we compare the absolute difference.
+          if (Offset1 > Offset2)
+            std::swap(Offset1, Offset2);
+
           // If the tail provided a bit enough offset, return noalias!
           if ((uint64_t)(Offset2-Offset1) >= SizeMax)
             return NoAlias;
+          // Otherwise break - we don't look for another constant in the tail.
+          break;
         }
     }
 

Modified: llvm/branches/non-call-eh/lib/Analysis/CFGPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/CFGPrinter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/CFGPrinter.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/CFGPrinter.cpp Sun Jul  6 15:45:41 2008
@@ -110,11 +110,13 @@
       AU.setPreservesAll();
     }
   };
+}
 
-  char CFGViewer::ID = 0;
-  RegisterPass<CFGViewer> V0("view-cfg",
-                             "View CFG of function", false, true);
+char CFGViewer::ID = 0;
+static RegisterPass<CFGViewer>
+V0("view-cfg", "View CFG of function", false, true);
 
+namespace {
   struct VISIBILITY_HIDDEN CFGOnlyViewer : public FunctionPass {
     static char ID; // Pass identifcation, replacement for typeid
     CFGOnlyViewer() : FunctionPass((intptr_t)&ID) {}
@@ -132,11 +134,14 @@
       AU.setPreservesAll();
     }
   };
+}
 
-  char CFGOnlyViewer::ID = 0;
-  RegisterPass<CFGOnlyViewer> V1("view-cfg-only",
-                                 "View CFG of function (with no function bodies)", false, true);
+char CFGOnlyViewer::ID = 0;
+static RegisterPass<CFGOnlyViewer>
+V1("view-cfg-only",
+   "View CFG of function (with no function bodies)", false, true);
 
+namespace {
   struct VISIBILITY_HIDDEN CFGPrinter : public FunctionPass {
     static char ID; // Pass identification, replacement for typeid
     CFGPrinter() : FunctionPass((intptr_t)&ID) {}
@@ -161,11 +166,13 @@
       AU.setPreservesAll();
     }
   };
+}
 
-  char CFGPrinter::ID = 0;
-  RegisterPass<CFGPrinter> P1("print-cfg",
-                              "Print CFG of function to 'dot' file", false, true);
+char CFGPrinter::ID = 0;
+static RegisterPass<CFGPrinter>
+P1("print-cfg", "Print CFG of function to 'dot' file", false, true);
 
+namespace {
   struct VISIBILITY_HIDDEN CFGOnlyPrinter : public CFGPrinter {
     static char ID; // Pass identification, replacement for typeid
     CFGOnlyPrinter() : CFGPrinter((intptr_t)&ID) {}
@@ -182,13 +189,13 @@
       AU.setPreservesAll();
     }
   };
-
-  char CFGOnlyPrinter::ID = 0;
-  RegisterPass<CFGOnlyPrinter>
-  P2("print-cfg-only",
-     "Print CFG of function to 'dot' file (with no function bodies)", false, true);
 }
 
+char CFGOnlyPrinter::ID = 0;
+static RegisterPass<CFGOnlyPrinter>
+P2("print-cfg-only",
+   "Print CFG of function to 'dot' file (with no function bodies)", false, true);
+
 /// viewCFG - This function is meant for use from the debugger.  You can just
 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
 /// program, displaying the CFG of the current function.  This depends on there

Modified: llvm/branches/non-call-eh/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ConstantFolding.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/ConstantFolding.cpp Sun Jul  6 15:45:41 2008
@@ -65,8 +65,9 @@
     
     // Otherwise, add any offset that our operands provide.
     gep_type_iterator GTI = gep_type_begin(CE);
-    for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i, ++GTI) {
-      ConstantInt *CI = dyn_cast<ConstantInt>(CE->getOperand(i));
+    for (User::const_op_iterator i = CE->op_begin() + 1, e = CE->op_end();
+         i != e; ++i, ++GTI) {
+      ConstantInt *CI = dyn_cast<ConstantInt>(*i);
       if (!CI) return false;  // Index isn't a simple constant?
       if (CI->getZExtValue() == 0) continue;  // Not adding anything.
       
@@ -122,27 +123,32 @@
                                          const Type *ResultTy,
                                          const TargetData *TD) {
   Constant *Ptr = Ops[0];
-  if (!cast<PointerType>(Ptr->getType())->getElementType()->isSized())
+  if (!TD || !cast<PointerType>(Ptr->getType())->getElementType()->isSized())
     return 0;
   
-  if (TD && Ptr->isNullValue()) {
-    // If this is a constant expr gep that is effectively computing an
-    // "offsetof", fold it into 'cast int Size to T*' instead of 'gep 0, 0, 12'
-    bool isFoldableGEP = true;
-    for (unsigned i = 1; i != NumOps; ++i)
-      if (!isa<ConstantInt>(Ops[i])) {
-        isFoldableGEP = false;
-        break;
-      }
-    if (isFoldableGEP) {
-      uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
-                                             (Value**)Ops+1, NumOps-1);
-      Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset);
-      return ConstantExpr::getIntToPtr(C, ResultTy);
-    }
+  uint64_t BasePtr = 0;
+  if (!Ptr->isNullValue()) {
+    // If this is a inttoptr from a constant int, we can fold this as the base,
+    // otherwise we can't.
+    if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr))
+      if (CE->getOpcode() == Instruction::IntToPtr)
+        if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0)))
+          BasePtr = Base->getZExtValue();
+    
+    if (BasePtr == 0)
+      return 0;
   }
-  
-  return 0;
+
+  // If this is a constant expr gep that is effectively computing an
+  // "offsetof", fold it into 'cast int Size to T*' instead of 'gep 0, 0, 12'
+  for (unsigned i = 1; i != NumOps; ++i)
+    if (!isa<ConstantInt>(Ops[i]))
+      return false;
+  
+  uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
+                                         (Value**)Ops+1, NumOps-1);
+  Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr);
+  return ConstantExpr::getIntToPtr(C, ResultTy);
 }
 
 /// FoldBitCast - Constant fold bitcast, symbolically evaluating it with 
@@ -292,8 +298,8 @@
   // Scan the operand list, checking to see if they are all constants, if so,
   // hand off to ConstantFoldInstOperands.
   SmallVector<Constant*, 8> Ops;
-  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
-    if (Constant *Op = dyn_cast<Constant>(I->getOperand(i)))
+  for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
+    if (Constant *Op = dyn_cast<Constant>(*i))
       Ops.push_back(Op);
     else
       return 0;  // All operands not constant!
@@ -306,6 +312,25 @@
                                     &Ops[0], Ops.size(), TD);
 }
 
+/// ConstantFoldConstantExpression - Attempt to fold the constant expression
+/// using the specified TargetData.  If successful, the constant result is
+/// result is returned, if not, null is returned.
+Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE,
+                                               const TargetData *TD) {
+  assert(TD && "ConstantFoldConstantExpression requires a valid TargetData.");
+
+  SmallVector<Constant*, 8> Ops;
+  for (User::op_iterator i = CE->op_begin(), e = CE->op_end(); i != e; ++i)
+    Ops.push_back(cast<Constant>(*i));
+
+  if (CE->isCompare())
+    return ConstantFoldCompareInstOperands(CE->getPredicate(),
+                                           &Ops[0], Ops.size(), TD);
+  else 
+    return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(),
+                                    &Ops[0], Ops.size(), TD);
+}
+
 /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
 /// specified opcode and operands.  If successful, the constant result is
 /// returned, if not, null is returned.  Note that this function can fail when
@@ -392,7 +417,7 @@
                                                 const TargetData *TD) {
   // fold: icmp (inttoptr x), null         -> icmp x, 0
   // fold: icmp (ptrtoint x), 0            -> icmp x, null
-  // fold: icmp (inttoptr x), (inttoptr y) -> icmp x, y
+  // fold: icmp (inttoptr x), (inttoptr y) -> icmp trunc/zext x, trunc/zext y
   // fold: icmp (ptrtoint x), (ptrtoint y) -> icmp x, y
   //
   // ConstantExpr::getCompare cannot do this, because it doesn't have TD
@@ -420,21 +445,31 @@
       }
     }
     
-    if (TD && isa<ConstantExpr>(Ops[1]) &&
-        cast<ConstantExpr>(Ops[1])->getOpcode() == CE0->getOpcode()) {
-      const Type *IntPtrTy = TD->getIntPtrType();
-      // Only do this transformation if the int is intptrty in size, otherwise
-      // there is a truncation or extension that we aren't modeling.
-      if ((CE0->getOpcode() == Instruction::IntToPtr &&
-           CE0->getOperand(0)->getType() == IntPtrTy &&
-           Ops[1]->getOperand(0)->getType() == IntPtrTy) ||
-          (CE0->getOpcode() == Instruction::PtrToInt &&
-           CE0->getType() == IntPtrTy &&
-           CE0->getOperand(0)->getType() == Ops[1]->getOperand(0)->getType())) {
-        Constant *NewOps[] = { 
-          CE0->getOperand(0), cast<ConstantExpr>(Ops[1])->getOperand(0) 
-        };
-        return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD);
+    if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(Ops[1])) {
+      if (TD && CE0->getOpcode() == CE1->getOpcode()) {
+        const Type *IntPtrTy = TD->getIntPtrType();
+
+        if (CE0->getOpcode() == Instruction::IntToPtr) {
+          // Convert the integer value to the right size to ensure we get the
+          // proper extension or truncation.
+          Constant *C0 = ConstantExpr::getIntegerCast(CE0->getOperand(0),
+                                                      IntPtrTy, false);
+          Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0),
+                                                      IntPtrTy, false);
+          Constant *NewOps[] = { C0, C1 };
+          return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD);
+        }
+
+        // Only do this transformation if the int is intptrty in size, otherwise
+        // there is a truncation or extension that we aren't modeling.
+        if ((CE0->getOpcode() == Instruction::PtrToInt &&
+             CE0->getType() == IntPtrTy &&
+             CE0->getOperand(0)->getType() == CE1->getOperand(0)->getType())) {
+          Constant *NewOps[] = { 
+            CE0->getOperand(0), CE1->getOperand(0) 
+          };
+          return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD);
+        }
       }
     }
   }
@@ -597,6 +632,7 @@
   if (Ty == Type::DoubleTy)
     return ConstantFP::get(APFloat(V));
   assert(0 && "Can only constant fold float/double");
+  return 0; // dummy return to suppress warning
 }
 
 static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),
@@ -614,6 +650,7 @@
   if (Ty == Type::DoubleTy)
     return ConstantFP::get(APFloat(V));
   assert(0 && "Can only constant fold float/double");
+  return 0; // dummy return to suppress warning
 }
 
 /// ConstantFoldCall - Attempt to constant fold a call to the specified function

Modified: llvm/branches/non-call-eh/lib/Analysis/IPA/Andersens.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/IPA/Andersens.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/IPA/Andersens.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/IPA/Andersens.cpp Sun Jul  6 15:45:41 2008
@@ -89,14 +89,14 @@
 STATISTIC(NumUnified    , "Number of variables unified");
 STATISTIC(NumErased     , "Number of redundant constraints erased");
 
-namespace {
-  const unsigned SelfRep = (unsigned)-1;
-  const unsigned Unvisited = (unsigned)-1;
-  // Position of the function return node relative to the function node.
-  const unsigned CallReturnPos = 1;
-  // Position of the function call node relative to the function node.
-  const unsigned CallFirstArgPos = 2;
+static const unsigned SelfRep = (unsigned)-1;
+static const unsigned Unvisited = (unsigned)-1;
+// Position of the function return node relative to the function node.
+static const unsigned CallReturnPos = 1;
+// Position of the function call node relative to the function node.
+static const unsigned CallFirstArgPos = 2;
 
+namespace {
   struct BitmapKeyInfo {
     static inline SparseBitVector<> *getEmptyKey() {
       return reinterpret_cast<SparseBitVector<> *>(-1);
@@ -608,16 +608,15 @@
       PrintPointsToGraph();
     }
   };
+}
 
-  char Andersens::ID = 0;
-  RegisterPass<Andersens> X("anders-aa",
-                            "Andersen's Interprocedural Alias Analysis", false,
-                            true);
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
+char Andersens::ID = 0;
+static RegisterPass<Andersens>
+X("anders-aa", "Andersen's Interprocedural Alias Analysis", false, true);
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
 
-  // Initialize Timestamp Counter (static).
-  unsigned Andersens::Node::Counter = 0;
-}
+// Initialize Timestamp Counter (static).
+unsigned Andersens::Node::Counter = 0;
 
 ModulePass *llvm::createAndersensPass() { return new Andersens(); }
 
@@ -864,7 +863,7 @@
 /// object N, which contains values indicated by C.
 void Andersens::AddGlobalInitializerConstraints(unsigned NodeIndex,
                                                 Constant *C) {
-  if (C->getType()->isFirstClassType()) {
+  if (C->getType()->isSingleValueType()) {
     if (isa<PointerType>(C->getType()))
       Constraints.push_back(Constraint(Constraint::Copy, NodeIndex,
                                        getNodeForConstantPointer(C)));
@@ -2725,13 +2724,14 @@
   DOUT << "\n";
 
   if (SDTActive)
-    if (SDT[Second] >= 0)
+    if (SDT[Second] >= 0) {
       if (SDT[First] < 0)
         SDT[First] = SDT[Second];
       else {
         UniteNodes( FindNode(SDT[First]), FindNode(SDT[Second]) );
         First = FindNode(First);
       }
+    }
 
   return First;
 }

Modified: llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraph.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraph.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraph.cpp Sun Jul  6 15:45:41 2008
@@ -26,9 +26,7 @@
 /// takes the address of the function.
 static bool isOnlyADirectCall(Function *F, CallSite CS) {
   if (!CS.getInstruction()) return false;
-  for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
-    if (*I == F) return false;
-  return true;
+  return !CS.hasArgument(F);
 }
 
 namespace {
@@ -190,12 +188,13 @@
   }
 };
 
-RegisterAnalysisGroup<CallGraph> X("Call Graph");
-RegisterPass<BasicCallGraph> Y("basiccg", "Basic CallGraph Construction", false, true);
-RegisterAnalysisGroup<CallGraph, true> Z(Y);
-
 } //End anonymous namespace
 
+static RegisterAnalysisGroup<CallGraph> X("Call Graph");
+static RegisterPass<BasicCallGraph>
+Y("basiccg", "Basic CallGraph Construction", false, true);
+static RegisterAnalysisGroup<CallGraph, true> Z(Y);
+
 char CallGraph::ID = 0;
 char BasicCallGraph::ID = 0;
 

Modified: llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraphSCCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraphSCCPass.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/IPA/CallGraphSCCPass.cpp Sun Jul  6 15:45:41 2008
@@ -27,6 +27,8 @@
 //
 /// CGPassManager manages FPPassManagers and CalLGraphSCCPasses.
 
+namespace {
+
 class CGPassManager : public ModulePass, public PMDataManager {
 
 public:
@@ -73,6 +75,8 @@
   }
 };
 
+}
+
 char CGPassManager::ID = 0;
 /// run - Execute all of the passes scheduled for execution.  Keep track of
 /// whether any of the passes modifies the module, and if so, return true.
@@ -158,6 +162,7 @@
          PMS.top()->getPassManagerType() > PMT_CallGraphPassManager)
     PMS.pop();
 
+  assert (!PMS.empty() && "Unable to handle Call Graph Pass");
   CGPassManager *CGP = dynamic_cast<CGPassManager *>(PMS.top());
 
   // Create new Call Graph SCC Pass Manager if it does not exist. 

Modified: llvm/branches/non-call-eh/lib/Analysis/IPA/FindUsedTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/IPA/FindUsedTypes.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/IPA/FindUsedTypes.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/IPA/FindUsedTypes.cpp Sun Jul  6 15:45:41 2008
@@ -96,6 +96,3 @@
        E = UsedTypes.end(); I != E; ++I)
     WriteTypeSymbolic(o << "  ", *I, M) << "\n";
 }
-
-// Ensure that this file gets linked in when FindUsedTypes.h is used.
-DEFINING_FILE_FOR(FindUsedTypes)

Modified: llvm/branches/non-call-eh/lib/Analysis/IPA/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/IPA/GlobalsModRef.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/IPA/GlobalsModRef.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/IPA/GlobalsModRef.cpp Sun Jul  6 15:45:41 2008
@@ -146,14 +146,13 @@
                               GlobalValue *OkayStoreDest = 0);
     bool AnalyzeIndirectGlobalMemory(GlobalValue *GV);
   };
-
-  char GlobalsModRef::ID = 0;
-  RegisterPass<GlobalsModRef> X("globalsmodref-aa",
-                                "Simple mod/ref analysis for globals", false,
-                                true);
-  RegisterAnalysisGroup<AliasAnalysis> Y(X);
 }
 
+char GlobalsModRef::ID = 0;
+static RegisterPass<GlobalsModRef>
+X("globalsmodref-aa", "Simple mod/ref analysis for globals", false, true);
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+
 Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); }
 
 /// getUnderlyingObject - This traverses the use chain to figure out what object

Modified: llvm/branches/non-call-eh/lib/Analysis/InstCount.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/InstCount.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/InstCount.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/InstCount.cpp Sun Jul  6 15:45:41 2008
@@ -62,12 +62,12 @@
     virtual void print(std::ostream &O, const Module *M) const {}
 
   };
-
-  char InstCount::ID = 0;
-  RegisterPass<InstCount> X("instcount",
-                            "Counts the various types of Instructions", false, true);
 }
 
+char InstCount::ID = 0;
+static RegisterPass<InstCount>
+X("instcount", "Counts the various types of Instructions", false, true);
+
 FunctionPass *llvm::createInstCountPass() { return new InstCount(); }
 
 // InstCount::run - This is the main Analysis entry point for a

Modified: llvm/branches/non-call-eh/lib/Analysis/IntervalPartition.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/IntervalPartition.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/IntervalPartition.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/IntervalPartition.cpp Sun Jul  6 15:45:41 2008
@@ -91,8 +91,7 @@
 //
 IntervalPartition::IntervalPartition(IntervalPartition &IP, bool)
   : FunctionPass((intptr_t) &ID) {
-  Interval *FunctionStart = IP.getRootInterval();
-  assert(FunctionStart && "Cannot operate on empty IntervalPartitions!");
+  assert(IP.getRootInterval() && "Cannot operate on empty IntervalPartitions!");
 
   // Pass false to intervals_begin because we take ownership of it's memory
   interval_part_interval_iterator I = intervals_begin(IP, false);

Added: llvm/branches/non-call-eh/lib/Analysis/LibCallAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/LibCallAliasAnalysis.cpp?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/LibCallAliasAnalysis.cpp (added)
+++ llvm/branches/non-call-eh/lib/Analysis/LibCallAliasAnalysis.cpp Sun Jul  6 15:45:41 2008
@@ -0,0 +1,141 @@
+//===- LibCallAliasAnalysis.cpp - Implement AliasAnalysis for libcalls ----===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the LibCallAliasAnalysis class.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/LibCallAliasAnalysis.h"
+#include "llvm/Analysis/Passes.h"
+#include "llvm/Analysis/LibCallSemantics.h"
+#include "llvm/Function.h"
+#include "llvm/Pass.h"
+#include "llvm/Target/TargetData.h"
+using namespace llvm;
+  
+// Register this pass...
+char LibCallAliasAnalysis::ID = 0;
+static RegisterPass<LibCallAliasAnalysis>
+X("libcall-aa", "LibCall Alias Analysis", false, true);
+  
+// Declare that we implement the AliasAnalysis interface
+static RegisterAnalysisGroup<AliasAnalysis> Y(X);
+
+FunctionPass *llvm::createLibCallAliasAnalysisPass(LibCallInfo *LCI) {
+  return new LibCallAliasAnalysis(LCI);
+}
+
+LibCallAliasAnalysis::~LibCallAliasAnalysis() {
+  delete LCI;
+}
+
+void LibCallAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
+  AliasAnalysis::getAnalysisUsage(AU);
+  AU.addRequired<TargetData>();
+  AU.setPreservesAll();                         // Does not transform code
+}
+
+
+
+/// AnalyzeLibCallDetails - Given a call to a function with the specified
+/// LibCallFunctionInfo, see if we can improve the mod/ref footprint of the call
+/// vs the specified pointer/size.
+AliasAnalysis::ModRefResult
+LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
+                                            CallSite CS, Value *P,
+                                            unsigned Size) {
+  // If we have a function, check to see what kind of mod/ref effects it
+  // has.  Start by including any info globally known about the function.
+  AliasAnalysis::ModRefResult MRInfo = FI->UniversalBehavior;
+  if (MRInfo == NoModRef) return MRInfo;
+  
+  // If that didn't tell us that the function is 'readnone', check to see
+  // if we have detailed info and if 'P' is any of the locations we know
+  // about.
+  const LibCallFunctionInfo::LocationMRInfo *Details = FI->LocationDetails;
+  if (Details == 0)
+    return MRInfo;
+  
+  // If the details array is of the 'DoesNot' kind, we only know something if
+  // the pointer is a match for one of the locations in 'Details'.  If we find a
+  // match, we can prove some interactions cannot happen.
+  // 
+  if (FI->DetailsType == LibCallFunctionInfo::DoesNot) {
+    // Find out if the pointer refers to a known location.
+    for (unsigned i = 0; Details[i].LocationID != ~0U; ++i) {
+      const LibCallLocationInfo &Loc =
+      LCI->getLocationInfo(Details[i].LocationID);
+      LibCallLocationInfo::LocResult Res = Loc.isLocation(CS, P, Size);
+      if (Res != LibCallLocationInfo::Yes) continue;
+      
+      // If we find a match against a location that we 'do not' interact with,
+      // learn this info into MRInfo.
+      return ModRefResult(MRInfo & ~Details[i].MRInfo);
+    }
+    return MRInfo;
+  }
+  
+  // If the details are of the 'DoesOnly' sort, we know something if the pointer
+  // is a match for one of the locations in 'Details'.  Also, if we can prove
+  // that the pointers is *not* one of the locations in 'Details', we know that
+  // the call is NoModRef.
+  assert(FI->DetailsType == LibCallFunctionInfo::DoesOnly);
+  
+  // Find out if the pointer refers to a known location.
+  bool NoneMatch = true;
+  for (unsigned i = 0; Details[i].LocationID != ~0U; ++i) {
+    const LibCallLocationInfo &Loc =
+    LCI->getLocationInfo(Details[i].LocationID);
+    LibCallLocationInfo::LocResult Res = Loc.isLocation(CS, P, Size);
+    if (Res == LibCallLocationInfo::No) continue;
+    
+    // If we don't know if this pointer points to the location, then we have to
+    // assume it might alias in some case.
+    if (Res == LibCallLocationInfo::Unknown) {
+      NoneMatch = false;
+      continue;
+    }
+    
+    // If we know that this pointer definitely is pointing into the location,
+    // merge in this information.
+    return ModRefResult(MRInfo & Details[i].MRInfo);
+  }
+  
+  // If we found that the pointer is guaranteed to not match any of the
+  // locations in our 'DoesOnly' rule, then we know that the pointer must point
+  // to some other location.  Since the libcall doesn't mod/ref any other
+  // locations, return NoModRef.
+  if (NoneMatch)
+    return NoModRef;
+  
+  // Otherwise, return any other info gained so far.
+  return MRInfo;
+}
+
+// getModRefInfo - Check to see if the specified callsite can clobber the
+// specified memory object.
+//
+AliasAnalysis::ModRefResult
+LibCallAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
+  ModRefResult MRInfo = ModRef;
+  
+  // If this is a direct call to a function that LCI knows about, get the
+  // information about the runtime function.
+  if (LCI) {
+    if (Function *F = CS.getCalledFunction()) {
+      if (const LibCallFunctionInfo *FI = LCI->getFunctionInfo(F)) {
+        MRInfo = ModRefResult(MRInfo & AnalyzeLibCallDetails(FI, CS, P, Size));
+        if (MRInfo == NoModRef) return NoModRef;
+      }
+    }
+  }
+  
+  // The AliasAnalysis base class has some smarts, lets use them.
+  return (ModRefResult)(MRInfo | AliasAnalysis::getModRefInfo(CS, P, Size));
+}

Added: llvm/branches/non-call-eh/lib/Analysis/LibCallSemantics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/LibCallSemantics.cpp?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/LibCallSemantics.cpp (added)
+++ llvm/branches/non-call-eh/lib/Analysis/LibCallSemantics.cpp Sun Jul  6 15:45:41 2008
@@ -0,0 +1,65 @@
+//===- LibCallSemantics.cpp - Describe library semantics ------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements interfaces that can be used to describe language
+// specific runtime library interfaces (e.g. libc, libm, etc) to LLVM
+// optimizers.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/LibCallSemantics.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Function.h"
+using namespace llvm;
+
+/// getMap - This impl pointer in ~LibCallInfo is actually a StringMap.  This
+/// helper does the cast.
+static StringMap<const LibCallFunctionInfo*> *getMap(void *Ptr) {
+  return static_cast<StringMap<const LibCallFunctionInfo*> *>(Ptr);
+}
+
+LibCallInfo::~LibCallInfo() {
+  delete getMap(Impl);
+}
+
+const LibCallLocationInfo &LibCallInfo::getLocationInfo(unsigned LocID) const {
+  // Get location info on the first call.
+  if (NumLocations == 0)
+    NumLocations = getLocationInfo(Locations);
+  
+  assert(LocID < NumLocations && "Invalid location ID!");
+  return Locations[LocID];
+}
+
+
+/// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to
+/// the specified function if we have it.  If not, return null.
+const LibCallFunctionInfo *LibCallInfo::getFunctionInfo(Function *F) const {
+  StringMap<const LibCallFunctionInfo*> *Map = getMap(Impl);
+  
+  /// If this is the first time we are querying for this info, lazily construct
+  /// the StringMap to index it.
+  if (Map == 0) {
+    Impl = Map = new StringMap<const LibCallFunctionInfo*>();
+    
+    const LibCallFunctionInfo *Array = getFunctionInfoArray();
+    if (Array == 0) return 0;
+    
+    // We now have the array of entries.  Populate the StringMap.
+    for (unsigned i = 0; Array[i].Name; ++i)
+      (*Map)[Array[i].Name] = Array+i;
+  }
+  
+  // Look up this function in the string map.
+  const char *ValueName = F->getNameStart();
+  StringMap<const LibCallFunctionInfo*>::iterator I =
+  Map->find(ValueName, ValueName+F->getNameLen());
+  return I != Map->end() ? I->second : 0;
+}
+

Modified: llvm/branches/non-call-eh/lib/Analysis/LoadValueNumbering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/LoadValueNumbering.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/LoadValueNumbering.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/LoadValueNumbering.cpp Sun Jul  6 15:45:41 2008
@@ -82,14 +82,15 @@
     void getCallEqualNumberNodes(CallInst *CI,
                                  std::vector<Value*> &RetVals) const;
   };
+}
 
-  char LoadVN::ID = 0;
-  // Register this pass...
-  RegisterPass<LoadVN> X("load-vn", "Load Value Numbering", false, true);
+char LoadVN::ID = 0;
+// Register this pass...
+static RegisterPass<LoadVN>
+X("load-vn", "Load Value Numbering", false, true);
 
-  // Declare that we implement the ValueNumbering interface
-  RegisterAnalysisGroup<ValueNumbering> Y(X);
-}
+// Declare that we implement the ValueNumbering interface
+static RegisterAnalysisGroup<ValueNumbering> Y(X);
 
 FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); }
 
@@ -157,10 +158,10 @@
   // global.  In particular, we would prefer to have an argument or instruction
   // operand to chase the def-use chains of.
   Value *Op = CF;
-  for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
-    if (isa<Argument>(CI->getOperand(i)) ||
-        isa<Instruction>(CI->getOperand(i))) {
-      Op = CI->getOperand(i);
+  for (User::op_iterator i = CI->op_begin() + 1, e = CI->op_end(); i != e; ++i)
+    if (isa<Argument>(*i) ||
+        isa<Instruction>(*i)) {
+      Op = *i;
       break;
     }
 
@@ -175,8 +176,9 @@
           C->getOperand(0) == CI->getOperand(0) &&
           C->getParent()->getParent() == CIFunc && C != CI) {
         bool AllOperandsEqual = true;
-        for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
-          if (C->getOperand(i) != CI->getOperand(i)) {
+        for (User::op_iterator i = CI->op_begin() + 1, j = C->op_begin() + 1,
+             e = CI->op_end(); i != e; ++i, ++j)
+          if (*j != *i) {
             AllOperandsEqual = false;
             break;
           }

Modified: llvm/branches/non-call-eh/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/LoopInfo.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/LoopInfo.cpp Sun Jul  6 15:45:41 2008
@@ -51,6 +51,3 @@
   AU.setPreservesAll();
   AU.addRequired<DominatorTree>();
 }
-
-// Ensure this file gets linked when LoopInfo.h is used.
-DEFINING_FILE_FOR(LoopInfo)

Modified: llvm/branches/non-call-eh/lib/Analysis/LoopPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/LoopPass.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/LoopPass.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/LoopPass.cpp Sun Jul  6 15:45:41 2008
@@ -184,6 +184,9 @@
   LI = &getAnalysis<LoopInfo>();
   bool Changed = false;
 
+  // Collect inherited analysis from Module level pass manager.
+  populateInheritedAnalysis(TPM->activeStack);
+
   // Populate Loop Queue
   for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
     addLoopIntoQueue(*I, LQ);
@@ -234,6 +237,9 @@
       recordAvailableAnalysis(P);
       removeDeadPasses(P, "", ON_LOOP_MSG);
 
+      // If dominator information is available then verify the info if requested.
+      verifyDomInfo(*LP, F);
+
       if (skipThisLoop)
         // Do not run other passes on this loop.
         break;

Added: llvm/branches/non-call-eh/lib/Analysis/LoopVR.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/LoopVR.cpp?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/LoopVR.cpp (added)
+++ llvm/branches/non-call-eh/lib/Analysis/LoopVR.cpp Sun Jul  6 15:45:41 2008
@@ -0,0 +1,289 @@
+//===- LoopVR.cpp - Value Range analysis driven by loop information -------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define DEBUG_TYPE "loopvr"
+#include "llvm/Analysis/LoopVR.h"
+#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/Assembly/Writer.h"
+#include "llvm/Support/CFG.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Streams.h"
+using namespace llvm;
+
+char LoopVR::ID = 0;
+namespace {
+static RegisterPass<LoopVR> X("loopvr", "Loop Value Ranges", true, true);
+}
+
+/// getRange - determine the range for a particular SCEV within a given Loop
+ConstantRange LoopVR::getRange(SCEVHandle S, Loop *L, ScalarEvolution &SE) {
+  SCEVHandle T = SE.getIterationCount(L);
+  if (isa<SCEVCouldNotCompute>(T))
+    return ConstantRange(cast<IntegerType>(S->getType())->getBitWidth(), true);
+
+  T = SE.getTruncateOrZeroExtend(T, S->getType());
+  return getRange(S, T, SE);
+}
+
+/// getRange - determine the range for a particular SCEV with a given trip count
+ConstantRange LoopVR::getRange(SCEVHandle S, SCEVHandle T, ScalarEvolution &SE){
+
+  if (SCEVConstant *C = dyn_cast<SCEVConstant>(S))
+    return ConstantRange(C->getValue()->getValue());
+
+  ConstantRange FullSet(cast<IntegerType>(S->getType())->getBitWidth(), true);
+
+  // {x,+,y,+,...z}. We detect overflow by checking the size of the set after
+  // summing the upper and lower.
+  if (SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(S)) {
+    ConstantRange X = getRange(Add->getOperand(0), T, SE);
+    if (X.isFullSet()) return FullSet;
+    for (unsigned i = 1, e = Add->getNumOperands(); i != e; ++i) {
+      ConstantRange Y = getRange(Add->getOperand(i), T, SE);
+      if (Y.isFullSet()) return FullSet;
+
+      APInt Spread_X = X.getSetSize(), Spread_Y = Y.getSetSize();
+      APInt NewLower = X.getLower() + Y.getLower();
+      APInt NewUpper = X.getUpper() + Y.getUpper() - 1;
+      if (NewLower == NewUpper)
+        return FullSet;
+
+      X = ConstantRange(NewLower, NewUpper);
+      if (X.getSetSize().ult(Spread_X) || X.getSetSize().ult(Spread_Y))
+        return FullSet; // we've wrapped, therefore, full set.
+    }
+    return X;
+  }
+
+  // {x,*,y,*,...,z}. In order to detect overflow, we use k*bitwidth where
+  // k is the number of terms being multiplied.
+  if (SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(S)) {
+    ConstantRange X = getRange(Mul->getOperand(0), T, SE);
+    if (X.isFullSet()) return FullSet;
+
+    const IntegerType *Ty = IntegerType::get(X.getBitWidth());
+    const IntegerType *ExTy = IntegerType::get(X.getBitWidth() *
+                                               Mul->getNumOperands());
+    ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth());
+
+    for (unsigned i = 1, e = Mul->getNumOperands(); i != e; ++i) {
+      ConstantRange Y = getRange(Mul->getOperand(i), T, SE);
+      if (Y.isFullSet()) return FullSet;
+
+      ConstantRange YExt = Y.zeroExtend(ExTy->getBitWidth());
+      XExt = ConstantRange(XExt.getLower() * YExt.getLower(),
+                           ((XExt.getUpper()-1) * (YExt.getUpper()-1)) + 1);
+    }
+    return XExt.truncate(Ty->getBitWidth());
+  }
+
+  // X smax Y smax ... Z is: range(smax(X_smin, Y_smin, ..., Z_smin),
+  //                               smax(X_smax, Y_smax, ..., Z_smax))
+  // It doesn't matter if one of the SCEVs has FullSet because we're taking
+  // a maximum of the minimums across all of them.
+  if (SCEVSMaxExpr *SMax = dyn_cast<SCEVSMaxExpr>(S)) {
+    ConstantRange X = getRange(SMax->getOperand(0), T, SE);
+    if (X.isFullSet()) return FullSet;
+
+    APInt smin = X.getSignedMin(), smax = X.getSignedMax();
+    for (unsigned i = 1, e = SMax->getNumOperands(); i != e; ++i) {
+      ConstantRange Y = getRange(SMax->getOperand(i), T, SE);
+      smin = APIntOps::smax(smin, Y.getSignedMin());
+      smax = APIntOps::smax(smax, Y.getSignedMax());
+    }
+    if (smax + 1 == smin) return FullSet;
+    return ConstantRange(smin, smax + 1);
+  }
+
+  // X umax Y umax ... Z is: range(umax(X_umin, Y_umin, ..., Z_umin),
+  //                               umax(X_umax, Y_umax, ..., Z_umax))
+  // It doesn't matter if one of the SCEVs has FullSet because we're taking
+  // a maximum of the minimums across all of them.
+  if (SCEVUMaxExpr *UMax = dyn_cast<SCEVUMaxExpr>(S)) {
+    ConstantRange X = getRange(UMax->getOperand(0), T, SE);
+    if (X.isFullSet()) return FullSet;
+
+    APInt umin = X.getUnsignedMin(), umax = X.getUnsignedMax();
+    for (unsigned i = 1, e = UMax->getNumOperands(); i != e; ++i) {
+      ConstantRange Y = getRange(UMax->getOperand(i), T, SE);
+      umin = APIntOps::umax(umin, Y.getUnsignedMin());
+      umax = APIntOps::umax(umax, Y.getUnsignedMax());
+    }
+    if (umax + 1 == umin) return FullSet;
+    return ConstantRange(umin, umax + 1);
+  }
+
+  // L udiv R. Luckily, there's only ever 2 sides to a udiv.
+  if (SCEVUDivExpr *UDiv = dyn_cast<SCEVUDivExpr>(S)) {
+    ConstantRange L = getRange(UDiv->getLHS(), T, SE);
+    ConstantRange R = getRange(UDiv->getRHS(), T, SE);
+    if (L.isFullSet() && R.isFullSet()) return FullSet;
+
+    if (R.getUnsignedMax() == 0) {
+      // RHS must be single-element zero. Return an empty set.
+      return ConstantRange(R.getBitWidth(), false);
+    }
+
+    APInt Lower = L.getUnsignedMin().udiv(R.getUnsignedMax());
+
+    APInt Upper;
+
+    if (R.getUnsignedMin() == 0) {
+      // Just because it contains zero, doesn't mean it will also contain one.
+      // Use maximalIntersectWith to get the right behaviour.
+      ConstantRange NotZero(APInt(L.getBitWidth(), 1),
+                            APInt::getNullValue(L.getBitWidth()));
+      R = R.maximalIntersectWith(NotZero);
+    }
+ 
+    // But, the maximal intersection might still include zero. If it does, then
+    // we know it also included one.
+    if (R.contains(APInt::getNullValue(L.getBitWidth())))
+      Upper = L.getUnsignedMax();
+    else
+      Upper = L.getUnsignedMax().udiv(R.getUnsignedMin());
+
+    return ConstantRange(Lower, Upper);
+  }
+
+  // ConstantRange already implements the cast operators.
+
+  if (SCEVZeroExtendExpr *ZExt = dyn_cast<SCEVZeroExtendExpr>(S)) {
+    T = SE.getTruncateOrZeroExtend(T, ZExt->getOperand()->getType());
+    ConstantRange X = getRange(ZExt->getOperand(), T, SE);
+    return X.zeroExtend(cast<IntegerType>(ZExt->getType())->getBitWidth());
+  }
+
+  if (SCEVSignExtendExpr *SExt = dyn_cast<SCEVSignExtendExpr>(S)) {
+    T = SE.getTruncateOrZeroExtend(T, SExt->getOperand()->getType());
+    ConstantRange X = getRange(SExt->getOperand(), T, SE);
+    return X.signExtend(cast<IntegerType>(SExt->getType())->getBitWidth());
+  }
+
+  if (SCEVTruncateExpr *Trunc = dyn_cast<SCEVTruncateExpr>(S)) {
+    T = SE.getTruncateOrZeroExtend(T, Trunc->getOperand()->getType());
+    ConstantRange X = getRange(Trunc->getOperand(), T, SE);
+    if (X.isFullSet()) return FullSet;
+    return X.truncate(cast<IntegerType>(Trunc->getType())->getBitWidth());
+  }
+
+  if (SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(S)) {
+    SCEVConstant *Trip = dyn_cast<SCEVConstant>(T);
+    if (!Trip) return FullSet;
+
+    if (AddRec->isAffine()) {
+      SCEVHandle StartHandle = AddRec->getStart();
+      SCEVHandle StepHandle = AddRec->getOperand(1);
+
+      SCEVConstant *Step = dyn_cast<SCEVConstant>(StepHandle);
+      if (!Step) return FullSet;
+
+      uint32_t ExWidth = 2 * Trip->getValue()->getBitWidth();
+      APInt TripExt = Trip->getValue()->getValue(); TripExt.zext(ExWidth);
+      APInt StepExt = Step->getValue()->getValue(); StepExt.zext(ExWidth);
+      if ((TripExt * StepExt).ugt(APInt::getLowBitsSet(ExWidth, ExWidth >> 1)))
+        return FullSet;
+
+      SCEVHandle EndHandle = SE.getAddExpr(StartHandle,
+                                           SE.getMulExpr(T, StepHandle));
+      SCEVConstant *Start = dyn_cast<SCEVConstant>(StartHandle);
+      SCEVConstant *End = dyn_cast<SCEVConstant>(EndHandle);
+      if (!Start || !End) return FullSet;
+
+      const APInt &StartInt = Start->getValue()->getValue();
+      const APInt &EndInt = End->getValue()->getValue();
+      const APInt &StepInt = Step->getValue()->getValue();
+
+      if (StepInt.isNegative()) {
+        if (EndInt == StartInt + 1) return FullSet;
+        return ConstantRange(EndInt, StartInt + 1);
+      } else {
+        if (StartInt == EndInt + 1) return FullSet;
+        return ConstantRange(StartInt, EndInt + 1);
+      }
+    }
+  }
+
+  // TODO: non-affine addrec, udiv, SCEVUnknown (narrowed from elsewhere)?
+
+  return FullSet;
+}
+
+bool LoopVR::runOnFunction(Function &F) { Map.clear(); return false; }
+
+void LoopVR::print(std::ostream &os, const Module *) const {
+  for (std::map<Value *, ConstantRange *>::const_iterator I = Map.begin(),
+       E = Map.end(); I != E; ++I) {
+    os << *I->first << ": ";
+    I->second->print(os);
+    os << "\n";
+  }
+}
+
+void LoopVR::releaseMemory() {
+  for (std::map<Value *, ConstantRange *>::iterator I = Map.begin(),
+       E = Map.end(); I != E; ++I) {
+    delete I->second;
+  }
+
+  Map.clear();  
+}
+
+ConstantRange LoopVR::compute(Value *V) {
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
+    return ConstantRange(CI->getValue());
+
+  Instruction *I = dyn_cast<Instruction>(V);
+  if (!I)
+    return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
+
+  LoopInfo &LI = getAnalysis<LoopInfo>();
+  ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
+
+  Loop *L = LI.getLoopFor(I->getParent());
+  if (L->isLoopInvariant(I))
+    return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
+
+  SCEVHandle S = SE.getSCEV(I);
+  if (isa<SCEVUnknown>(S) || isa<SCEVCouldNotCompute>(S))
+    return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
+
+  return ConstantRange(getRange(S, L, SE));
+}
+
+ConstantRange LoopVR::get(Value *V) {
+  std::map<Value *, ConstantRange *>::iterator I = Map.find(V);
+  if (I == Map.end()) {
+    ConstantRange *CR = new ConstantRange(compute(V));
+    Map[V] = CR;
+    return *CR;
+  }
+
+  return *I->second;
+}
+
+void LoopVR::remove(Value *V) {
+  std::map<Value *, ConstantRange *>::iterator I = Map.find(V);
+  if (I != Map.end()) {
+    delete I->second;
+    Map.erase(I);
+  }
+}
+
+void LoopVR::narrow(Value *V, const ConstantRange &CR) {
+  if (CR.isFullSet()) return;
+
+  std::map<Value *, ConstantRange *>::iterator I = Map.find(V);
+  if (I == Map.end())
+    Map[V] = new ConstantRange(CR);
+  else
+    Map[V] = new ConstantRange(Map[V]->maximalIntersectWith(CR));
+}

Modified: llvm/branches/non-call-eh/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/MemoryDependenceAnalysis.cpp Sun Jul  6 15:45:41 2008
@@ -28,14 +28,12 @@
 
 using namespace llvm;
 
-namespace {
-  // Control the calculation of non-local dependencies by only examining the
-  // predecessors if the basic block has less than X amount (50 by default).
-  cl::opt<int> 
-  PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
-            cl::desc("Control the calculation of non-local"
-                     "dependencies (default = 50)"));           
-}
+// Control the calculation of non-local dependencies by only examining the
+// predecessors if the basic block has less than X amount (50 by default).
+static cl::opt<int> 
+PredLimit("nonlocaldep-threshold", cl::Hidden, cl::init(50),
+          cl::desc("Control the calculation of non-local"
+                   "dependencies (default = 50)"));           
 
 STATISTIC(NumCacheNonlocal, "Number of cached non-local responses");
 STATISTIC(NumUncacheNonlocal, "Number of uncached non-local responses");
@@ -60,6 +58,9 @@
   for (nonLocalDepMapType::iterator I = depGraphNonLocal.begin(), E = depGraphNonLocal.end();
        I != E; ++I) {
     assert(I->first != D);
+    for (DenseMap<BasicBlock*, Value*>::iterator II = I->second.begin(),
+         EE = I->second.end(); II  != EE; ++II)
+      assert(II->second != D);
   }
 
   for (reverseDepMapType::iterator I = reverseDep.begin(), E = reverseDep.end();
@@ -131,7 +132,7 @@
       
       // FreeInsts erase the entire structure
       pointerSize = ~0UL;
-    } else if (isa<CallInst>(QI)) {
+    } else if (CallSite::get(QI).getInstruction() != 0) {
       AliasAnalysis::ModRefBehavior result =
                    AA.getModRefBehavior(CallSite::get(QI));
       if (result != AliasAnalysis::DoesNotAccessMemory) {
@@ -281,6 +282,11 @@
     
     resp = cached;
     
+    // Update the reverse non-local dependency cache
+    for (DenseMap<BasicBlock*, Value*>::iterator I = resp.begin(), E = resp.end();
+         I != E; ++I)
+      reverseDepNonLocal[I->second].insert(query);
+    
     return;
   } else
     NumUncacheNonlocal++;

Modified: llvm/branches/non-call-eh/lib/Analysis/PostDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/PostDominators.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/PostDominators.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/PostDominators.cpp Sun Jul  6 15:45:41 2008
@@ -37,6 +37,15 @@
   return false;
 }
 
+PostDominatorTree::~PostDominatorTree()
+{
+  delete DT;
+}
+
+FunctionPass* llvm::createPostDomTree() {
+  return new PostDominatorTree();
+}
+
 //===----------------------------------------------------------------------===//
 //  PostDominanceFrontier Implementation
 //===----------------------------------------------------------------------===//
@@ -80,5 +89,6 @@
   return S;
 }
 
-// Ensure that this .cpp file gets linked when PostDominators.h is used.
-DEFINING_FILE_FOR(PostDominanceFrontier)
+FunctionPass* llvm::createPostDomFrontier() {
+  return new PostDominanceFrontier();
+}

Modified: llvm/branches/non-call-eh/lib/Analysis/ProfileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ProfileInfo.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ProfileInfo.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/ProfileInfo.cpp Sun Jul  6 15:45:41 2008
@@ -21,9 +21,7 @@
 using namespace llvm;
 
 // Register the ProfileInfo interface, providing a nice name to refer to.
-namespace {
-  RegisterAnalysisGroup<ProfileInfo> Z("Profile Information");
-}
+static RegisterAnalysisGroup<ProfileInfo> Z("Profile Information");
 char ProfileInfo::ID = 0;
 
 ProfileInfo::~ProfileInfo() {}
@@ -89,14 +87,14 @@
     static char ID; // Class identification, replacement for typeinfo
     NoProfileInfo() : ImmutablePass((intptr_t)&ID) {}
   };
+}  // End of anonymous namespace
 
-  char NoProfileInfo::ID = 0;
-  // Register this pass...
-  RegisterPass<NoProfileInfo>
-  X("no-profile", "No Profile Information", false, true);
+char NoProfileInfo::ID = 0;
+// Register this pass...
+static RegisterPass<NoProfileInfo>
+X("no-profile", "No Profile Information", false, true);
 
-  // Declare that we implement the ProfileInfo interface
-  RegisterAnalysisGroup<ProfileInfo, true> Y(X);
-}  // End of anonymous namespace
+// Declare that we implement the ProfileInfo interface
+static RegisterAnalysisGroup<ProfileInfo, true> Y(X);
 
 ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }

Modified: llvm/branches/non-call-eh/lib/Analysis/ProfileInfoLoaderPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ProfileInfoLoaderPass.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ProfileInfoLoaderPass.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/ProfileInfoLoaderPass.cpp Sun Jul  6 15:45:41 2008
@@ -23,12 +23,12 @@
 #include "llvm/Support/Streams.h"
 using namespace llvm;
 
-namespace {
-  cl::opt<std::string>
-  ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"),
-                      cl::value_desc("filename"),
-                      cl::desc("Profile file loaded by -profile-loader"));
+static cl::opt<std::string>
+ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"),
+                    cl::value_desc("filename"),
+                    cl::desc("Profile file loaded by -profile-loader"));
 
+namespace {
   class VISIBILITY_HIDDEN LoaderPass : public ModulePass, public ProfileInfo {
     std::string Filename;
   public:
@@ -49,13 +49,13 @@
     /// run - Load the profile information from the specified file.
     virtual bool runOnModule(Module &M);
   };
+}  // End of anonymous namespace
 
-  char LoaderPass::ID = 0;
-  RegisterPass<LoaderPass>
-  X("profile-loader", "Load profile information from llvmprof.out", false, true);
+char LoaderPass::ID = 0;
+static RegisterPass<LoaderPass>
+X("profile-loader", "Load profile information from llvmprof.out", false, true);
 
-  RegisterAnalysisGroup<ProfileInfo> Y(X);
-}  // End of anonymous namespace
+static RegisterAnalysisGroup<ProfileInfo> Y(X);
 
 ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); }
 

Modified: llvm/branches/non-call-eh/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ScalarEvolution.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/ScalarEvolution.cpp Sun Jul  6 15:45:41 2008
@@ -95,16 +95,14 @@
 STATISTIC(NumBruteForceTripCountsComputed,
           "Number of loops with trip counts computed by force");
 
-cl::opt<unsigned>
+static cl::opt<unsigned>
 MaxBruteForceIterations("scalar-evolution-max-iterations", cl::ReallyHidden,
                         cl::desc("Maximum number of iterations SCEV will "
                                  "symbolically execute a constant derived loop"),
                         cl::init(100));
 
-namespace {
-  RegisterPass<ScalarEvolution>
-  R("scalar-evolution", "Scalar Evolution Analysis", false, true);
-}
+static RegisterPass<ScalarEvolution>
+R("scalar-evolution", "Scalar Evolution Analysis", false, true);
 char ScalarEvolution::ID = 0;
 
 //===----------------------------------------------------------------------===//
@@ -134,6 +132,12 @@
   return 0;
 }
 
+bool SCEV::isZero() const {
+  if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(this))
+    return SC->getValue()->isZero();
+  return false;
+}
+
 
 SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {}
 
@@ -501,21 +505,6 @@
   return getUnknown(C);
 }
 
-/// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion of the
-/// input value to the specified type.  If the type must be extended, it is zero
-/// extended.
-static SCEVHandle getTruncateOrZeroExtend(const SCEVHandle &V, const Type *Ty,
-                                          ScalarEvolution &SE) {
-  const Type *SrcTy = V->getType();
-  assert(SrcTy->isInteger() && Ty->isInteger() &&
-         "Cannot truncate or zero extend with non-integer arguments!");
-  if (SrcTy->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return V;  // No conversion
-  if (SrcTy->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits())
-    return SE.getTruncateExpr(V, Ty);
-  return SE.getZeroExtendExpr(V, Ty);
-}
-
 /// getNegativeSCEV - Return a SCEV corresponding to -V = -1*V
 ///
 SCEVHandle ScalarEvolution::getNegativeSCEV(const SCEVHandle &V) {
@@ -587,7 +576,7 @@
 #endif
 
   const IntegerType *DividendTy = IntegerType::get(DividendBits);
-  const SCEVHandle ExIt = SE.getZeroExtendExpr(It, DividendTy);
+  const SCEVHandle ExIt = SE.getTruncateOrZeroExtend(It, DividendTy);
 
   // The final number of bits we need to perform the division is the maximum of
   // dividend and divisor bitwidths.
@@ -609,7 +598,12 @@
       Dividend *= N-(K-1);
     if (DividendTy != DivisionTy)
       Dividend = Dividend.zext(DivisionTy->getBitWidth());
-    return SE.getConstant(Dividend.udiv(Divisor).trunc(It->getBitWidth()));
+
+    APInt Result = Dividend.udiv(Divisor);
+    if (Result.getBitWidth() != It->getBitWidth())
+      Result = Result.trunc(It->getBitWidth());
+
+    return SE.getConstant(Result);
   }
   
   SCEVHandle Dividend = ExIt;
@@ -617,11 +611,12 @@
     Dividend =
       SE.getMulExpr(Dividend,
                     SE.getMinusSCEV(ExIt, SE.getIntegerSCEV(i, DividendTy)));
-  if (DividendTy != DivisionTy)
-    Dividend = SE.getZeroExtendExpr(Dividend, DivisionTy);
-  return
-    SE.getTruncateExpr(SE.getUDivExpr(Dividend, SE.getConstant(Divisor)),
-                       It->getType());
+
+  return SE.getTruncateOrZeroExtend(
+             SE.getUDivExpr(
+                 SE.getTruncateOrZeroExtend(Dividend, DivisionTy),
+                 SE.getConstant(Divisor)
+             ), It->getType());
 }
 
 /// evaluateAtIteration - Return the value of this chain of recurrences at
@@ -705,6 +700,21 @@
   return Result;
 }
 
+/// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion
+/// of the input value to the specified type.  If the type must be
+/// extended, it is zero extended.
+SCEVHandle ScalarEvolution::getTruncateOrZeroExtend(const SCEVHandle &V,
+                                                    const Type *Ty) {
+  const Type *SrcTy = V->getType();
+  assert(SrcTy->isInteger() && Ty->isInteger() &&
+         "Cannot truncate or zero extend with non-integer arguments!");
+  if (SrcTy->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
+    return V;  // No conversion
+  if (SrcTy->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits())
+    return getTruncateExpr(V, Ty);
+  return getZeroExtendExpr(V, Ty);
+}
+
 // get - Get a canonical add expression, or something simpler if possible.
 SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) {
   assert(!Ops.empty() && "Cannot get empty add!");
@@ -1132,11 +1142,10 @@
                                const Loop *L) {
   if (Operands.size() == 1) return Operands[0];
 
-  if (SCEVConstant *StepC = dyn_cast<SCEVConstant>(Operands.back()))
-    if (StepC->getValue()->isZero()) {
-      Operands.pop_back();
-      return getAddRecExpr(Operands, L);             // { X,+,0 }  -->  X
-    }
+  if (Operands.back()->isZero()) {
+    Operands.pop_back();
+    return getAddRecExpr(Operands, L);             // { X,+,0 }  -->  X
+  }
 
   SCEVAddRecExpr *&Result =
     (*SCEVAddRecExprs)[std::make_pair(L, std::vector<SCEV*>(Operands.begin(),
@@ -1695,118 +1704,125 @@
   if (!isa<IntegerType>(V->getType()))
     return SE.getUnknown(V);
     
-  if (Instruction *I = dyn_cast<Instruction>(V)) {
-    switch (I->getOpcode()) {
-    case Instruction::Add:
-      return SE.getAddExpr(getSCEV(I->getOperand(0)),
-                           getSCEV(I->getOperand(1)));
-    case Instruction::Mul:
-      return SE.getMulExpr(getSCEV(I->getOperand(0)),
-                           getSCEV(I->getOperand(1)));
-    case Instruction::UDiv:
-      return SE.getUDivExpr(getSCEV(I->getOperand(0)),
-                            getSCEV(I->getOperand(1)));
-    case Instruction::Sub:
-      return SE.getMinusSCEV(getSCEV(I->getOperand(0)),
-                             getSCEV(I->getOperand(1)));
-    case Instruction::Or:
-      // If the RHS of the Or is a constant, we may have something like:
-      // X*4+1 which got turned into X*4|1.  Handle this as an Add so loop
-      // optimizations will transparently handle this case.
-      //
-      // In order for this transformation to be safe, the LHS must be of the
-      // form X*(2^n) and the Or constant must be less than 2^n.
-      if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
-        SCEVHandle LHS = getSCEV(I->getOperand(0));
-        const APInt &CIVal = CI->getValue();
-        if (GetMinTrailingZeros(LHS) >=
-            (CIVal.getBitWidth() - CIVal.countLeadingZeros()))
-          return SE.getAddExpr(LHS, getSCEV(I->getOperand(1)));
-      }
-      break;
-    case Instruction::Xor:
-      // If the RHS of the xor is a signbit, then this is just an add.
-      // Instcombine turns add of signbit into xor as a strength reduction step.
-      if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
-        if (CI->getValue().isSignBit())
-          return SE.getAddExpr(getSCEV(I->getOperand(0)),
-                               getSCEV(I->getOperand(1)));
-        else if (CI->isAllOnesValue())
-          return SE.getNotSCEV(getSCEV(I->getOperand(0)));
-      }
-      break;
+  unsigned Opcode = Instruction::UserOp1;
+  if (Instruction *I = dyn_cast<Instruction>(V))
+    Opcode = I->getOpcode();
+  else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
+    Opcode = CE->getOpcode();
+  else
+    return SE.getUnknown(V);
 
-    case Instruction::Shl:
-      // Turn shift left of a constant amount into a multiply.
-      if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
-        uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
-        Constant *X = ConstantInt::get(
-          APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth)));
-        return SE.getMulExpr(getSCEV(I->getOperand(0)), getSCEV(X));
-      }
-      break;
+  User *U = cast<User>(V);
+  switch (Opcode) {
+  case Instruction::Add:
+    return SE.getAddExpr(getSCEV(U->getOperand(0)),
+                         getSCEV(U->getOperand(1)));
+  case Instruction::Mul:
+    return SE.getMulExpr(getSCEV(U->getOperand(0)),
+                         getSCEV(U->getOperand(1)));
+  case Instruction::UDiv:
+    return SE.getUDivExpr(getSCEV(U->getOperand(0)),
+                          getSCEV(U->getOperand(1)));
+  case Instruction::Sub:
+    return SE.getMinusSCEV(getSCEV(U->getOperand(0)),
+                           getSCEV(U->getOperand(1)));
+  case Instruction::Or:
+    // If the RHS of the Or is a constant, we may have something like:
+    // X*4+1 which got turned into X*4|1.  Handle this as an Add so loop
+    // optimizations will transparently handle this case.
+    //
+    // In order for this transformation to be safe, the LHS must be of the
+    // form X*(2^n) and the Or constant must be less than 2^n.
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(U->getOperand(1))) {
+      SCEVHandle LHS = getSCEV(U->getOperand(0));
+      const APInt &CIVal = CI->getValue();
+      if (GetMinTrailingZeros(LHS) >=
+          (CIVal.getBitWidth() - CIVal.countLeadingZeros()))
+        return SE.getAddExpr(LHS, getSCEV(U->getOperand(1)));
+    }
+    break;
+  case Instruction::Xor:
+    // If the RHS of the xor is a signbit, then this is just an add.
+    // Instcombine turns add of signbit into xor as a strength reduction step.
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(U->getOperand(1))) {
+      if (CI->getValue().isSignBit())
+        return SE.getAddExpr(getSCEV(U->getOperand(0)),
+                             getSCEV(U->getOperand(1)));
+      else if (CI->isAllOnesValue())
+        return SE.getNotSCEV(getSCEV(U->getOperand(0)));
+    }
+    break;
 
-    case Instruction::Trunc:
-      return SE.getTruncateExpr(getSCEV(I->getOperand(0)), I->getType());
+  case Instruction::Shl:
+    // Turn shift left of a constant amount into a multiply.
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(U->getOperand(1))) {
+      uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
+      Constant *X = ConstantInt::get(
+        APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth)));
+      return SE.getMulExpr(getSCEV(U->getOperand(0)), getSCEV(X));
+    }
+    break;
 
-    case Instruction::ZExt:
-      return SE.getZeroExtendExpr(getSCEV(I->getOperand(0)), I->getType());
+  case Instruction::Trunc:
+    return SE.getTruncateExpr(getSCEV(U->getOperand(0)), U->getType());
 
-    case Instruction::SExt:
-      return SE.getSignExtendExpr(getSCEV(I->getOperand(0)), I->getType());
-
-    case Instruction::BitCast:
-      // BitCasts are no-op casts so we just eliminate the cast.
-      if (I->getType()->isInteger() &&
-          I->getOperand(0)->getType()->isInteger())
-        return getSCEV(I->getOperand(0));
-      break;
-
-    case Instruction::PHI:
-      return createNodeForPHI(cast<PHINode>(I));
-
-    case Instruction::Select:
-      // This could be a smax or umax that was lowered earlier.
-      // Try to recover it.
-      if (ICmpInst *ICI = dyn_cast<ICmpInst>(I->getOperand(0))) {
-        Value *LHS = ICI->getOperand(0);
-        Value *RHS = ICI->getOperand(1);
-        switch (ICI->getPredicate()) {
-        case ICmpInst::ICMP_SLT:
-        case ICmpInst::ICMP_SLE:
-          std::swap(LHS, RHS);
-          // fall through
-        case ICmpInst::ICMP_SGT:
-        case ICmpInst::ICMP_SGE:
-          if (LHS == I->getOperand(1) && RHS == I->getOperand(2))
-            return SE.getSMaxExpr(getSCEV(LHS), getSCEV(RHS));
-          else if (LHS == I->getOperand(2) && RHS == I->getOperand(1))
-            // -smax(-x, -y) == smin(x, y).
-            return SE.getNegativeSCEV(SE.getSMaxExpr(
-                                          SE.getNegativeSCEV(getSCEV(LHS)),
-                                          SE.getNegativeSCEV(getSCEV(RHS))));
-          break;
-        case ICmpInst::ICMP_ULT:
-        case ICmpInst::ICMP_ULE:
-          std::swap(LHS, RHS);
-          // fall through
-        case ICmpInst::ICMP_UGT:
-        case ICmpInst::ICMP_UGE:
-          if (LHS == I->getOperand(1) && RHS == I->getOperand(2))
-            return SE.getUMaxExpr(getSCEV(LHS), getSCEV(RHS));
-          else if (LHS == I->getOperand(2) && RHS == I->getOperand(1))
-            // ~umax(~x, ~y) == umin(x, y)
-            return SE.getNotSCEV(SE.getUMaxExpr(SE.getNotSCEV(getSCEV(LHS)),
-                                                SE.getNotSCEV(getSCEV(RHS))));
-          break;
-        default:
-          break;
-        }
-      }
+  case Instruction::ZExt:
+    return SE.getZeroExtendExpr(getSCEV(U->getOperand(0)), U->getType());
+
+  case Instruction::SExt:
+    return SE.getSignExtendExpr(getSCEV(U->getOperand(0)), U->getType());
+
+  case Instruction::BitCast:
+    // BitCasts are no-op casts so we just eliminate the cast.
+    if (U->getType()->isInteger() &&
+        U->getOperand(0)->getType()->isInteger())
+      return getSCEV(U->getOperand(0));
+    break;
+
+  case Instruction::PHI:
+    return createNodeForPHI(cast<PHINode>(U));
 
-    default: // We cannot analyze this expression.
-      break;
+  case Instruction::Select:
+    // This could be a smax or umax that was lowered earlier.
+    // Try to recover it.
+    if (ICmpInst *ICI = dyn_cast<ICmpInst>(U->getOperand(0))) {
+      Value *LHS = ICI->getOperand(0);
+      Value *RHS = ICI->getOperand(1);
+      switch (ICI->getPredicate()) {
+      case ICmpInst::ICMP_SLT:
+      case ICmpInst::ICMP_SLE:
+        std::swap(LHS, RHS);
+        // fall through
+      case ICmpInst::ICMP_SGT:
+      case ICmpInst::ICMP_SGE:
+        if (LHS == U->getOperand(1) && RHS == U->getOperand(2))
+          return SE.getSMaxExpr(getSCEV(LHS), getSCEV(RHS));
+        else if (LHS == U->getOperand(2) && RHS == U->getOperand(1))
+          // -smax(-x, -y) == smin(x, y).
+          return SE.getNegativeSCEV(SE.getSMaxExpr(
+                                        SE.getNegativeSCEV(getSCEV(LHS)),
+                                        SE.getNegativeSCEV(getSCEV(RHS))));
+        break;
+      case ICmpInst::ICMP_ULT:
+      case ICmpInst::ICMP_ULE:
+        std::swap(LHS, RHS);
+        // fall through
+      case ICmpInst::ICMP_UGT:
+      case ICmpInst::ICMP_UGE:
+        if (LHS == U->getOperand(1) && RHS == U->getOperand(2))
+          return SE.getUMaxExpr(getSCEV(LHS), getSCEV(RHS));
+        else if (LHS == U->getOperand(2) && RHS == U->getOperand(1))
+          // ~umax(~x, ~y) == umin(x, y)
+          return SE.getNotSCEV(SE.getUMaxExpr(SE.getNotSCEV(getSCEV(LHS)),
+                                              SE.getNotSCEV(getSCEV(RHS))));
+        break;
+      default:
+        break;
+      }
     }
+
+  default: // We cannot analyze this expression.
+    break;
   }
 
   return SE.getUnknown(V);
@@ -1981,7 +1997,7 @@
   }
   case ICmpInst::ICMP_UGT: {
     SCEVHandle TC = HowManyLessThans(SE.getNotSCEV(LHS),
-                  SE.getNotSCEV(RHS), L, false);
+                                     SE.getNotSCEV(RHS), L, false);
     if (!isa<SCEVCouldNotCompute>(TC)) return TC;
     break;
   }
@@ -2045,7 +2061,7 @@
 }
 
 /// ComputeLoadConstantCompareIterationCount - Given an exit condition of
-/// 'icmp op load X, cst', try to se if we can compute the trip count.
+/// 'icmp op load X, cst', try to see if we can compute the trip count.
 SCEVHandle ScalarEvolutionsImpl::
 ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS,
                                          const Loop *L, 
@@ -2434,8 +2450,8 @@
       // loop iterates.  Compute this now.
       SCEVHandle IterationCount = getIterationCount(AddRec->getLoop());
       if (IterationCount == UnknownValue) return UnknownValue;
-      IterationCount = getTruncateOrZeroExtend(IterationCount,
-                                               AddRec->getType(), SE);
+      IterationCount = SE.getTruncateOrZeroExtend(IterationCount,
+                                                  AddRec->getType());
 
       // If the value is affine, simplify the expression evaluation to just
       // Start + Step*IterationCount.
@@ -2550,9 +2566,9 @@
       if (SCEVConstant *StartC = dyn_cast<SCEVConstant>(Start)) {
         ConstantInt *StartCC = StartC->getValue();
         Constant *StartNegC = ConstantExpr::getNeg(StartCC);
-        Constant *Rem = ConstantExpr::getSRem(StartNegC, StepC->getValue());
+        Constant *Rem = ConstantExpr::getURem(StartNegC, StepC->getValue());
         if (Rem->isNullValue()) {
-          Constant *Result =ConstantExpr::getSDiv(StartNegC,StepC->getValue());
+          Constant *Result = ConstantExpr::getUDiv(StartNegC,StepC->getValue());
           return SE.getUnknown(Result);
         }
       }
@@ -2579,9 +2595,8 @@
         // value at this index.  When solving for "X*X != 5", for example, we
         // should not accept a root of 2.
         SCEVHandle Val = AddRec->evaluateAtIteration(R1, SE);
-        if (SCEVConstant *EvalVal = dyn_cast<SCEVConstant>(Val))
-          if (EvalVal->getValue()->isZero())
-            return R1;  // We found a quadratic root!
+        if (Val->isZero())
+          return R1;  // We found a quadratic root!
       }
     }
   }

Modified: llvm/branches/non-call-eh/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ScalarEvolutionExpander.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/ScalarEvolutionExpander.cpp Sun Jul  6 15:45:41 2008
@@ -40,7 +40,7 @@
             return CI;
           }
     }
-    return CastInst::create(opcode, V, Ty, V->getName(), 
+    return CastInst::Create(opcode, V, Ty, V->getName(), 
                             A->getParent()->getEntryBlock().begin());
   }
 
@@ -67,13 +67,13 @@
   if (InvokeInst *II = dyn_cast<InvokeInst>(I))
     IP = II->getNormalDest()->begin();
   while (isa<PHINode>(IP)) ++IP;
-  return CastInst::create(opcode, V, Ty, V->getName(), IP);
+  return CastInst::Create(opcode, V, Ty, V->getName(), IP);
 }
 
 /// InsertBinop - Insert the specified binary operator, doing a small amount
 /// of work to avoid inserting an obviously redundant operation.
 Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
-                                 Value *RHS, Instruction *&InsertPt) {
+                                 Value *RHS, Instruction *InsertPt) {
   // Fold a binop with constant operands.
   if (Constant *CLHS = dyn_cast<Constant>(LHS))
     if (Constant *CRHS = dyn_cast<Constant>(RHS))
@@ -81,24 +81,34 @@
 
   // Do a quick scan to see if we have this binop nearby.  If so, reuse it.
   unsigned ScanLimit = 6;
-  for (BasicBlock::iterator IP = InsertPt, E = InsertPt->getParent()->begin();
-       ScanLimit; --IP, --ScanLimit) {
-    if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(IP))
-      if (BinOp->getOpcode() == Opcode && BinOp->getOperand(0) == LHS &&
-          BinOp->getOperand(1) == RHS) {
-        // If we found the instruction *at* the insert point, insert later
-        // instructions after it.
-        if (BinOp == InsertPt)
-          InsertPt = ++IP;
-        return BinOp;
-      }
-    if (IP == E) break;
+  BasicBlock::iterator BlockBegin = InsertPt->getParent()->begin();
+  if (InsertPt != BlockBegin) {
+    // Scanning starts from the last instruction before InsertPt.
+    BasicBlock::iterator IP = InsertPt;
+    --IP;
+    for (; ScanLimit; --IP, --ScanLimit) {
+      if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(IP))
+        if (BinOp->getOpcode() == Opcode && BinOp->getOperand(0) == LHS &&
+            BinOp->getOperand(1) == RHS)
+          return BinOp;
+      if (IP == BlockBegin) break;
+    }
   }
-
-  // If we don't have 
-  return BinaryOperator::create(Opcode, LHS, RHS, "tmp", InsertPt);
+  
+  // If we haven't found this binop, insert it.
+  return BinaryOperator::Create(Opcode, LHS, RHS, "tmp", InsertPt);
 }
 
+Value *SCEVExpander::visitAddExpr(SCEVAddExpr *S) {
+  Value *V = expand(S->getOperand(S->getNumOperands()-1));
+
+  // Emit a bunch of add instructions
+  for (int i = S->getNumOperands()-2; i >= 0; --i)
+    V = InsertBinop(Instruction::Add, V, expand(S->getOperand(i)),
+                    InsertPt);
+  return V;
+}
+    
 Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
   int FirstOp = 0;  // Set if we should emit a subtract.
   if (SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getOperand(0)))
@@ -126,8 +136,7 @@
   assert(Ty->isInteger() && "Cannot expand fp recurrences yet!");
 
   // {X,+,F} --> X + {0,+,F}
-  if (!isa<SCEVConstant>(S->getStart()) ||
-      !cast<SCEVConstant>(S->getStart())->getValue()->isZero()) {
+  if (!S->getStart()->isZero()) {
     Value *Start = expand(S->getStart());
     std::vector<SCEVHandle> NewOps(S->op_begin(), S->op_end());
     NewOps[0] = SE.getIntegerSCEV(0, Ty);
@@ -138,7 +147,7 @@
   }
 
   // {0,+,1} --> Insert a canonical induction variable into the loop!
-  if (S->getNumOperands() == 2 &&
+  if (S->isAffine() &&
       S->getOperand(1) == SE.getIntegerSCEV(1, Ty)) {
     // Create and insert the PHI node for the induction variable in the
     // specified loop.
@@ -155,7 +164,7 @@
     // Insert a unit add instruction right before the terminator corresponding
     // to the back-edge.
     Constant *One = ConstantInt::get(Ty, 1);
-    Instruction *Add = BinaryOperator::createAdd(PN, One, "indvar.next",
+    Instruction *Add = BinaryOperator::CreateAdd(PN, One, "indvar.next",
                                                  (*HPI)->getTerminator());
 
     pred_iterator PI = pred_begin(Header);
@@ -169,7 +178,7 @@
   Value *I = getOrInsertCanonicalInductionVariable(L, Ty);
 
   // If this is a simple linear addrec, emit it now as a special case.
-  if (S->getNumOperands() == 2) {   // {0,+,F} --> i*F
+  if (S->isAffine()) {   // {0,+,F} --> i*F
     Value *F = expand(S->getOperand(1));
     
     // IF the step is by one, just return the inserted IV.
@@ -185,14 +194,21 @@
     Loop *InsertPtLoop = LI.getLoopFor(MulInsertPt->getParent());
     if (InsertPtLoop != L && InsertPtLoop &&
         L->contains(InsertPtLoop->getHeader())) {
-      while (InsertPtLoop != L) {
+      do {
         // If we cannot hoist the multiply out of this loop, don't.
         if (!InsertPtLoop->isLoopInvariant(F)) break;
 
-        // Otherwise, move the insert point to the preheader of the loop.
-        MulInsertPt = InsertPtLoop->getLoopPreheader()->getTerminator();
+        BasicBlock *InsertPtLoopPH = InsertPtLoop->getLoopPreheader();
+
+        // If this loop hasn't got a preheader, we aren't able to hoist the
+        // multiply.
+        if (!InsertPtLoopPH)
+          break;
+
+        // Otherwise, move the insert point to the preheader.
+        MulInsertPt = InsertPtLoopPH->getTerminator();
         InsertPtLoop = InsertPtLoop->getParentLoop();
-      }
+      } while (InsertPtLoop != L);
     }
     
     return InsertBinop(Instruction::Mul, I, F, MulInsertPt);
@@ -210,6 +226,21 @@
   return expand(V);
 }
 
+Value *SCEVExpander::visitTruncateExpr(SCEVTruncateExpr *S) {
+  Value *V = expand(S->getOperand());
+  return CastInst::createTruncOrBitCast(V, S->getType(), "tmp.", InsertPt);
+}
+
+Value *SCEVExpander::visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
+  Value *V = expand(S->getOperand());
+  return CastInst::createZExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
+}
+
+Value *SCEVExpander::visitSignExtendExpr(SCEVSignExtendExpr *S) {
+  Value *V = expand(S->getOperand());
+  return CastInst::createSExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
+}
+
 Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) {
   Value *LHS = expand(S->getOperand(0));
   for (unsigned i = 1; i < S->getNumOperands(); ++i) {
@@ -230,6 +261,12 @@
   return LHS;
 }
 
+Value *SCEVExpander::expandCodeFor(SCEVHandle SH, Instruction *IP) {
+  // Expand the code for this SCEV.
+  this->InsertPt = IP;
+  return expand(SH);
+}
+
 Value *SCEVExpander::expand(SCEV *S) {
   // Check to see if we already expanded this.
   std::map<SCEVHandle, Value*>::iterator I = InsertedExpressions.find(S);

Added: llvm/branches/non-call-eh/lib/Analysis/SparsePropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/SparsePropagation.cpp?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/SparsePropagation.cpp (added)
+++ llvm/branches/non-call-eh/lib/Analysis/SparsePropagation.cpp Sun Jul  6 15:45:41 2008
@@ -0,0 +1,329 @@
+//===- SparsePropagation.cpp - Sparse Conditional Property Propagation ----===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements an abstract sparse conditional propagation algorithm,
+// modeled after SCCP, but with a customizable lattice function.
+//
+//===----------------------------------------------------------------------===//
+
+#define DEBUG_TYPE "sparseprop"
+#include "llvm/Analysis/SparsePropagation.h"
+#include "llvm/Constants.h"
+#include "llvm/Function.h"
+#include "llvm/Instructions.h"
+#include "llvm/Support/Debug.h"
+using namespace llvm;
+
+//===----------------------------------------------------------------------===//
+//                  AbstractLatticeFunction Implementation
+//===----------------------------------------------------------------------===//
+
+AbstractLatticeFunction::~AbstractLatticeFunction() {}
+
+/// PrintValue - Render the specified lattice value to the specified stream.
+void AbstractLatticeFunction::PrintValue(LatticeVal V, std::ostream &OS) {
+  if (V == UndefVal)
+    OS << "undefined";
+  else if (V == OverdefinedVal)
+    OS << "overdefined";
+  else if (V == UntrackedVal)
+    OS << "untracked";
+  else
+    OS << "unknown lattice value";
+}
+
+//===----------------------------------------------------------------------===//
+//                          SparseSolver Implementation
+//===----------------------------------------------------------------------===//
+
+/// getOrInitValueState - Return the LatticeVal object that corresponds to the
+/// value, initializing the value's state if it hasn't been entered into the
+/// map yet.   This function is necessary because not all values should start
+/// out in the underdefined state... Arguments should be overdefined, and
+/// constants should be marked as constants.
+///
+SparseSolver::LatticeVal SparseSolver::getOrInitValueState(Value *V) {
+  DenseMap<Value*, LatticeVal>::iterator I = ValueState.find(V);
+  if (I != ValueState.end()) return I->second;  // Common case, in the map
+  
+  LatticeVal LV;
+  if (LatticeFunc->IsUntrackedValue(V))
+    return LatticeFunc->getUntrackedVal();
+  else if (Constant *C = dyn_cast<Constant>(V))
+    LV = LatticeFunc->ComputeConstant(C);
+  else if (!isa<Instruction>(V))
+    // Non-instructions (e.g. formal arguments) are overdefined.
+    LV = LatticeFunc->getOverdefinedVal();
+  else
+    // All instructions are underdefined by default.
+    LV = LatticeFunc->getUndefVal();
+  
+  // If this value is untracked, don't add it to the map.
+  if (LV == LatticeFunc->getUntrackedVal())
+    return LV;
+  return ValueState[V] = LV;
+}
+
+/// UpdateState - When the state for some instruction is potentially updated,
+/// this function notices and adds I to the worklist if needed.
+void SparseSolver::UpdateState(Instruction &Inst, LatticeVal V) {
+  DenseMap<Value*, LatticeVal>::iterator I = ValueState.find(&Inst);
+  if (I != ValueState.end() && I->second == V)
+    return;  // No change.
+  
+  // An update.  Visit uses of I.
+  ValueState[&Inst] = V;
+  InstWorkList.push_back(&Inst);
+}
+
+/// MarkBlockExecutable - This method can be used by clients to mark all of
+/// the blocks that are known to be intrinsically live in the processed unit.
+void SparseSolver::MarkBlockExecutable(BasicBlock *BB) {
+  DOUT << "Marking Block Executable: " << BB->getNameStart() << "\n";
+  BBExecutable.insert(BB);   // Basic block is executable!
+  BBWorkList.push_back(BB);  // Add the block to the work list!
+}
+
+/// markEdgeExecutable - Mark a basic block as executable, adding it to the BB
+/// work list if it is not already executable...
+void SparseSolver::markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) {
+  if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
+    return;  // This edge is already known to be executable!
+  
+  DOUT << "Marking Edge Executable: " << Source->getNameStart()
+       << " -> " << Dest->getNameStart() << "\n";
+
+  if (BBExecutable.count(Dest)) {
+    // The destination is already executable, but we just made an edge
+    // feasible that wasn't before.  Revisit the PHI nodes in the block
+    // because they have potentially new operands.
+    for (BasicBlock::iterator I = Dest->begin(); isa<PHINode>(I); ++I)
+      visitPHINode(*cast<PHINode>(I));
+    
+  } else {
+    MarkBlockExecutable(Dest);
+  }
+}
+
+
+/// getFeasibleSuccessors - Return a vector of booleans to indicate which
+/// successors are reachable from a given terminator instruction.
+void SparseSolver::getFeasibleSuccessors(TerminatorInst &TI,
+                                         SmallVectorImpl<bool> &Succs,
+                                         bool AggressiveUndef) {
+  Succs.resize(TI.getNumSuccessors());
+  if (TI.getNumSuccessors() == 0) return;
+  
+  if (BranchInst *BI = dyn_cast<BranchInst>(&TI)) {
+    if (BI->isUnconditional()) {
+      Succs[0] = true;
+      return;
+    }
+    
+    LatticeVal BCValue;
+    if (AggressiveUndef)
+      BCValue = getOrInitValueState(BI->getCondition());
+    else
+      BCValue = getLatticeState(BI->getCondition());
+    
+    if (BCValue == LatticeFunc->getOverdefinedVal() ||
+        BCValue == LatticeFunc->getUntrackedVal()) {
+      // Overdefined condition variables can branch either way.
+      Succs[0] = Succs[1] = true;
+      return;
+    }
+
+    // If undefined, neither is feasible yet.
+    if (BCValue == LatticeFunc->getUndefVal())
+      return;
+
+    Constant *C = LatticeFunc->GetConstant(BCValue, BI->getCondition(), *this);
+    if (C == 0 || !isa<ConstantInt>(C)) {
+      // Non-constant values can go either way.
+      Succs[0] = Succs[1] = true;
+      return;
+    }
+
+    // Constant condition variables mean the branch can only go a single way
+    Succs[C == ConstantInt::getFalse()] = true;
+    return;
+  }
+  
+  if (isa<InvokeInst>(TI)) {
+    // Invoke instructions successors are always executable.
+    // TODO: Could ask the lattice function if the value can throw.
+    Succs[0] = Succs[1] = true;
+    return;
+  }
+  
+  SwitchInst &SI = cast<SwitchInst>(TI);
+  LatticeVal SCValue;
+  if (AggressiveUndef)
+    SCValue = getOrInitValueState(SI.getCondition());
+  else
+    SCValue = getLatticeState(SI.getCondition());
+  
+  if (SCValue == LatticeFunc->getOverdefinedVal() ||
+      SCValue == LatticeFunc->getUntrackedVal()) {
+    // All destinations are executable!
+    Succs.assign(TI.getNumSuccessors(), true);
+    return;
+  }
+  
+  // If undefined, neither is feasible yet.
+  if (SCValue == LatticeFunc->getUndefVal())
+    return;
+  
+  Constant *C = LatticeFunc->GetConstant(SCValue, SI.getCondition(), *this);
+  if (C == 0 || !isa<ConstantInt>(C)) {
+    // All destinations are executable!
+    Succs.assign(TI.getNumSuccessors(), true);
+    return;
+  }
+  
+  Succs[SI.findCaseValue(cast<ConstantInt>(C))] = true;
+}
+
+
+/// isEdgeFeasible - Return true if the control flow edge from the 'From'
+/// basic block to the 'To' basic block is currently feasible...
+bool SparseSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To,
+                                  bool AggressiveUndef) {
+  SmallVector<bool, 16> SuccFeasible;
+  TerminatorInst *TI = From->getTerminator();
+  getFeasibleSuccessors(*TI, SuccFeasible, AggressiveUndef);
+  
+  for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
+    if (TI->getSuccessor(i) == To && SuccFeasible[i])
+      return true;
+  
+  return false;
+}
+
+void SparseSolver::visitTerminatorInst(TerminatorInst &TI) {
+  SmallVector<bool, 16> SuccFeasible;
+  getFeasibleSuccessors(TI, SuccFeasible, true);
+  
+  BasicBlock *BB = TI.getParent();
+  
+  // Mark all feasible successors executable...
+  for (unsigned i = 0, e = SuccFeasible.size(); i != e; ++i)
+    if (SuccFeasible[i])
+      markEdgeExecutable(BB, TI.getSuccessor(i));
+}
+
+void SparseSolver::visitPHINode(PHINode &PN) {
+  LatticeVal PNIV = getOrInitValueState(&PN);
+  LatticeVal Overdefined = LatticeFunc->getOverdefinedVal();
+  
+  // If this value is already overdefined (common) just return.
+  if (PNIV == Overdefined || PNIV == LatticeFunc->getUntrackedVal())
+    return;  // Quick exit
+  
+  // Super-extra-high-degree PHI nodes are unlikely to ever be interesting,
+  // and slow us down a lot.  Just mark them overdefined.
+  if (PN.getNumIncomingValues() > 64) {
+    UpdateState(PN, Overdefined);
+    return;
+  }
+  
+  // Look at all of the executable operands of the PHI node.  If any of them
+  // are overdefined, the PHI becomes overdefined as well.  Otherwise, ask the
+  // transfer function to give us the merge of the incoming values.
+  for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
+    // If the edge is not yet known to be feasible, it doesn't impact the PHI.
+    if (!isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent(), true))
+      continue;
+    
+    // Merge in this value.
+    LatticeVal OpVal = getOrInitValueState(PN.getIncomingValue(i));
+    if (OpVal != PNIV)
+      PNIV = LatticeFunc->MergeValues(PNIV, OpVal);
+    
+    if (PNIV == Overdefined)
+      break;  // Rest of input values don't matter.
+  }
+
+  // Update the PHI with the compute value, which is the merge of the inputs.
+  UpdateState(PN, PNIV);
+}
+
+
+void SparseSolver::visitInst(Instruction &I) {
+  // PHIs are handled by the propagation logic, they are never passed into the
+  // transfer functions.
+  if (PHINode *PN = dyn_cast<PHINode>(&I))
+    return visitPHINode(*PN);
+  
+  // Otherwise, ask the transfer function what the result is.  If this is
+  // something that we care about, remember it.
+  LatticeVal IV = LatticeFunc->ComputeInstructionState(I, *this);
+  if (IV != LatticeFunc->getUntrackedVal())
+    UpdateState(I, IV);
+  
+  if (TerminatorInst *TI = dyn_cast<TerminatorInst>(&I))
+    visitTerminatorInst(*TI);
+}
+
+void SparseSolver::Solve(Function &F) {
+  MarkBlockExecutable(&F.getEntryBlock());
+  
+  // Process the work lists until they are empty!
+  while (!BBWorkList.empty() || !InstWorkList.empty()) {
+    // Process the instruction work list.
+    while (!InstWorkList.empty()) {
+      Instruction *I = InstWorkList.back();
+      InstWorkList.pop_back();
+
+      DOUT << "\nPopped off I-WL: " << *I;
+
+      // "I" got into the work list because it made a transition.  See if any
+      // users are both live and in need of updating.
+      for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
+           UI != E; ++UI) {
+        Instruction *U = cast<Instruction>(*UI);
+        if (BBExecutable.count(U->getParent()))   // Inst is executable?
+          visitInst(*U);
+      }
+    }
+
+    // Process the basic block work list.
+    while (!BBWorkList.empty()) {
+      BasicBlock *BB = BBWorkList.back();
+      BBWorkList.pop_back();
+
+      DOUT << "\nPopped off BBWL: " << *BB;
+
+      // Notify all instructions in this basic block that they are newly
+      // executable.
+      for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+        visitInst(*I);
+    }
+  }
+}
+
+void SparseSolver::Print(Function &F, std::ostream &OS) {
+  OS << "\nFUNCTION: " << F.getNameStr() << "\n";
+  for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
+    if (!BBExecutable.count(BB))
+      OS << "INFEASIBLE: ";
+    OS << "\t";
+    if (BB->hasName())
+      OS << BB->getNameStr() << ":\n";
+    else
+      OS << "; anon bb\n";
+    for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
+      LatticeFunc->PrintValue(getLatticeState(I), OS);
+      OS << *I;
+    }
+    
+    OS << "\n";
+  }
+}
+

Modified: llvm/branches/non-call-eh/lib/Analysis/ValueNumbering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ValueNumbering.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ValueNumbering.cpp (original)
+++ llvm/branches/non-call-eh/lib/Analysis/ValueNumbering.cpp Sun Jul  6 15:45:41 2008
@@ -10,6 +10,10 @@
 // This file implements the non-abstract Value Numbering methods as well as a
 // default implementation for the analysis group.
 //
+// The ValueNumbering analysis pass is mostly deprecated. It is only used by the
+// Global Common Subexpression Elimination pass, which is deprecated by the
+// Global Value Numbering pass (which does its value numbering on its own).
+//
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/Passes.h"
@@ -24,7 +28,7 @@
 
 char ValueNumbering::ID = 0;
 // Register the ValueNumbering interface, providing a nice name to refer to.
-static RegisterAnalysisGroup<ValueNumbering> X("Value Numbering");
+static RegisterAnalysisGroup<ValueNumbering> V("Value Numbering");
 
 /// ValueNumbering destructor: DO NOT move this to the header file for
 /// ValueNumbering or else clients of the ValueNumbering class may not depend on
@@ -64,15 +68,17 @@
     virtual void getEqualNumberNodes(Value *V1,
                                      std::vector<Value*> &RetVals) const;
   };
+}
 
-  char BasicVN::ID = 0;
-  // Register this pass...
-  RegisterPass<BasicVN>
-  X("basicvn", "Basic Value Numbering (default GVN impl)", false, true);
+char BasicVN::ID = 0;
+// Register this pass...
+static RegisterPass<BasicVN>
+X("basicvn", "Basic Value Numbering (default GVN impl)", false, true);
 
-  // Declare that we implement the ValueNumbering interface
-  RegisterAnalysisGroup<ValueNumbering, true> Y(X);
+// Declare that we implement the ValueNumbering interface
+static RegisterAnalysisGroup<ValueNumbering, true> Y(X);
 
+namespace {
   /// BVNImpl - Implement BasicVN in terms of a visitor class that
   /// handles the different types of instructions as appropriate.
   ///
@@ -242,9 +248,9 @@
 
   // Try to pick a local operand if possible instead of a constant or a global
   // that might have a lot of uses.
-  for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i)
-    if (isa<Instruction>(I.getOperand(i)) || isa<Argument>(I.getOperand(i))) {
-      Op = I.getOperand(i);
+  for (User::op_iterator i = I.op_begin() + 1, e = I.op_end(); i != e; ++i)
+    if (isa<Instruction>(*i) || isa<Argument>(*i)) {
+      Op = *i;
       break;
     }
 

Added: llvm/branches/non-call-eh/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Analysis/ValueTracking.cpp?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/lib/Analysis/ValueTracking.cpp (added)
+++ llvm/branches/non-call-eh/lib/Analysis/ValueTracking.cpp Sun Jul  6 15:45:41 2008
@@ -0,0 +1,1032 @@
+//===- ValueTracking.cpp - Walk computations to compute properties --------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains routines that help analyze properties that chains of
+// computations have.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/IntrinsicInst.h"
+#include "llvm/Target/TargetData.h"
+#include "llvm/Support/GetElementPtrTypeIterator.h"
+#include "llvm/Support/MathExtras.h"
+#include <cstring>
+using namespace llvm;
+
+/// getOpcode - If this is an Instruction or a ConstantExpr, return the
+/// opcode value. Otherwise return UserOp1.
+static unsigned getOpcode(const Value *V) {
+  if (const Instruction *I = dyn_cast<Instruction>(V))
+    return I->getOpcode();
+  if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
+    return CE->getOpcode();
+  // Use UserOp1 to mean there's no opcode.
+  return Instruction::UserOp1;
+}
+
+
+/// ComputeMaskedBits - Determine which of the bits specified in Mask are
+/// known to be either zero or one and return them in the KnownZero/KnownOne
+/// bit sets.  This code only analyzes bits in Mask, in order to short-circuit
+/// processing.
+/// NOTE: we cannot consider 'undef' to be "IsZero" here.  The problem is that
+/// we cannot optimize based on the assumption that it is zero without changing
+/// it to be an explicit zero.  If we don't change it to zero, other code could
+/// optimized based on the contradictory assumption that it is non-zero.
+/// Because instcombine aggressively folds operations with undef args anyway,
+/// this won't lose us code quality.
+void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
+                             APInt &KnownZero, APInt &KnownOne,
+                             TargetData *TD, unsigned Depth) {
+  assert(V && "No Value?");
+  assert(Depth <= 6 && "Limit Search Depth");
+  uint32_t BitWidth = Mask.getBitWidth();
+  assert((V->getType()->isInteger() || isa<PointerType>(V->getType())) &&
+         "Not integer or pointer type!");
+  assert((!TD || TD->getTypeSizeInBits(V->getType()) == BitWidth) &&
+         (!isa<IntegerType>(V->getType()) ||
+          V->getType()->getPrimitiveSizeInBits() == BitWidth) &&
+         KnownZero.getBitWidth() == BitWidth && 
+         KnownOne.getBitWidth() == BitWidth &&
+         "V, Mask, KnownOne and KnownZero should have same BitWidth");
+
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
+    // We know all of the bits for a constant!
+    KnownOne = CI->getValue() & Mask;
+    KnownZero = ~KnownOne & Mask;
+    return;
+  }
+  // Null is all-zeros.
+  if (isa<ConstantPointerNull>(V)) {
+    KnownOne.clear();
+    KnownZero = Mask;
+    return;
+  }
+  // The address of an aligned GlobalValue has trailing zeros.
+  if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
+    unsigned Align = GV->getAlignment();
+    if (Align == 0 && TD && GV->getType()->getElementType()->isSized()) 
+      Align = TD->getPrefTypeAlignment(GV->getType()->getElementType());
+    if (Align > 0)
+      KnownZero = Mask & APInt::getLowBitsSet(BitWidth,
+                                              CountTrailingZeros_32(Align));
+    else
+      KnownZero.clear();
+    KnownOne.clear();
+    return;
+  }
+
+  KnownZero.clear(); KnownOne.clear();   // Start out not knowing anything.
+
+  if (Depth == 6 || Mask == 0)
+    return;  // Limit search depth.
+
+  User *I = dyn_cast<User>(V);
+  if (!I) return;
+
+  APInt KnownZero2(KnownZero), KnownOne2(KnownOne);
+  switch (getOpcode(I)) {
+  default: break;
+  case Instruction::And: {
+    // If either the LHS or the RHS are Zero, the result is zero.
+    ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, TD, Depth+1);
+    APInt Mask2(Mask & ~KnownZero);
+    ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
+                      Depth+1);
+    assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+    
+    // Output known-1 bits are only known if set in both the LHS & RHS.
+    KnownOne &= KnownOne2;
+    // Output known-0 are known to be clear if zero in either the LHS | RHS.
+    KnownZero |= KnownZero2;
+    return;
+  }
+  case Instruction::Or: {
+    ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, TD, Depth+1);
+    APInt Mask2(Mask & ~KnownOne);
+    ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
+                      Depth+1);
+    assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+    
+    // Output known-0 bits are only known if clear in both the LHS & RHS.
+    KnownZero &= KnownZero2;
+    // Output known-1 are known to be set if set in either the LHS | RHS.
+    KnownOne |= KnownOne2;
+    return;
+  }
+  case Instruction::Xor: {
+    ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, TD, Depth+1);
+    ComputeMaskedBits(I->getOperand(0), Mask, KnownZero2, KnownOne2, TD,
+                      Depth+1);
+    assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+    
+    // Output known-0 bits are known if clear or set in both the LHS & RHS.
+    APInt KnownZeroOut = (KnownZero & KnownZero2) | (KnownOne & KnownOne2);
+    // Output known-1 are known to be set if set in only one of the LHS, RHS.
+    KnownOne = (KnownZero & KnownOne2) | (KnownOne & KnownZero2);
+    KnownZero = KnownZeroOut;
+    return;
+  }
+  case Instruction::Mul: {
+    APInt Mask2 = APInt::getAllOnesValue(BitWidth);
+    ComputeMaskedBits(I->getOperand(1), Mask2, KnownZero, KnownOne, TD,Depth+1);
+    ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
+                      Depth+1);
+    assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+    
+    // If low bits are zero in either operand, output low known-0 bits.
+    // Also compute a conserative estimate for high known-0 bits.
+    // More trickiness is possible, but this is sufficient for the
+    // interesting case of alignment computation.
+    KnownOne.clear();
+    unsigned TrailZ = KnownZero.countTrailingOnes() +
+                      KnownZero2.countTrailingOnes();
+    unsigned LeadZ =  std::max(KnownZero.countLeadingOnes() +
+                               KnownZero2.countLeadingOnes(),
+                               BitWidth) - BitWidth;
+
+    TrailZ = std::min(TrailZ, BitWidth);
+    LeadZ = std::min(LeadZ, BitWidth);
+    KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) |
+                APInt::getHighBitsSet(BitWidth, LeadZ);
+    KnownZero &= Mask;
+    return;
+  }
+  case Instruction::UDiv: {
+    // For the purposes of computing leading zeros we can conservatively
+    // treat a udiv as a logical right shift by the power of 2 known to
+    // be less than the denominator.
+    APInt AllOnes = APInt::getAllOnesValue(BitWidth);
+    ComputeMaskedBits(I->getOperand(0),
+                      AllOnes, KnownZero2, KnownOne2, TD, Depth+1);
+    unsigned LeadZ = KnownZero2.countLeadingOnes();
+
+    KnownOne2.clear();
+    KnownZero2.clear();
+    ComputeMaskedBits(I->getOperand(1),
+                      AllOnes, KnownZero2, KnownOne2, TD, Depth+1);
+    unsigned RHSUnknownLeadingOnes = KnownOne2.countLeadingZeros();
+    if (RHSUnknownLeadingOnes != BitWidth)
+      LeadZ = std::min(BitWidth,
+                       LeadZ + BitWidth - RHSUnknownLeadingOnes - 1);
+
+    KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask;
+    return;
+  }
+  case Instruction::Select:
+    ComputeMaskedBits(I->getOperand(2), Mask, KnownZero, KnownOne, TD, Depth+1);
+    ComputeMaskedBits(I->getOperand(1), Mask, KnownZero2, KnownOne2, TD,
+                      Depth+1);
+    assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+
+    // Only known if known in both the LHS and RHS.
+    KnownOne &= KnownOne2;
+    KnownZero &= KnownZero2;
+    return;
+  case Instruction::FPTrunc:
+  case Instruction::FPExt:
+  case Instruction::FPToUI:
+  case Instruction::FPToSI:
+  case Instruction::SIToFP:
+  case Instruction::UIToFP:
+    return; // Can't work with floating point.
+  case Instruction::PtrToInt:
+  case Instruction::IntToPtr:
+    // We can't handle these if we don't know the pointer size.
+    if (!TD) return;
+    // FALL THROUGH and handle them the same as zext/trunc.
+  case Instruction::ZExt:
+  case Instruction::Trunc: {
+    // Note that we handle pointer operands here because of inttoptr/ptrtoint
+    // which fall through here.
+    const Type *SrcTy = I->getOperand(0)->getType();
+    uint32_t SrcBitWidth = TD ?
+      TD->getTypeSizeInBits(SrcTy) :
+      SrcTy->getPrimitiveSizeInBits();
+    APInt MaskIn(Mask);
+    MaskIn.zextOrTrunc(SrcBitWidth);
+    KnownZero.zextOrTrunc(SrcBitWidth);
+    KnownOne.zextOrTrunc(SrcBitWidth);
+    ComputeMaskedBits(I->getOperand(0), MaskIn, KnownZero, KnownOne, TD,
+                      Depth+1);
+    KnownZero.zextOrTrunc(BitWidth);
+    KnownOne.zextOrTrunc(BitWidth);
+    // Any top bits are known to be zero.
+    if (BitWidth > SrcBitWidth)
+      KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth);
+    return;
+  }
+  case Instruction::BitCast: {
+    const Type *SrcTy = I->getOperand(0)->getType();
+    if (SrcTy->isInteger() || isa<PointerType>(SrcTy)) {
+      ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, TD,
+                        Depth+1);
+      return;
+    }
+    break;
+  }
+  case Instruction::SExt: {
+    // Compute the bits in the result that are not present in the input.
+    const IntegerType *SrcTy = cast<IntegerType>(I->getOperand(0)->getType());
+    uint32_t SrcBitWidth = SrcTy->getBitWidth();
+      
+    APInt MaskIn(Mask); 
+    MaskIn.trunc(SrcBitWidth);
+    KnownZero.trunc(SrcBitWidth);
+    KnownOne.trunc(SrcBitWidth);
+    ComputeMaskedBits(I->getOperand(0), MaskIn, KnownZero, KnownOne, TD,
+                      Depth+1);
+    assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+    KnownZero.zext(BitWidth);
+    KnownOne.zext(BitWidth);
+
+    // If the sign bit of the input is known set or clear, then we know the
+    // top bits of the result.
+    if (KnownZero[SrcBitWidth-1])             // Input sign bit known zero
+      KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth);
+    else if (KnownOne[SrcBitWidth-1])           // Input sign bit known set
+      KnownOne |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth);
+    return;
+  }
+  case Instruction::Shl:
+    // (shl X, C1) & C2 == 0   iff   (X & C2 >>u C1) == 0
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      uint64_t ShiftAmt = SA->getLimitedValue(BitWidth);
+      APInt Mask2(Mask.lshr(ShiftAmt));
+      ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, KnownOne, TD,
+                        Depth+1);
+      assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+      KnownZero <<= ShiftAmt;
+      KnownOne  <<= ShiftAmt;
+      KnownZero |= APInt::getLowBitsSet(BitWidth, ShiftAmt); // low bits known 0
+      return;
+    }
+    break;
+  case Instruction::LShr:
+    // (ushr X, C1) & C2 == 0   iff  (-1 >> C1) & C2 == 0
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      // Compute the new bits that are at the top now.
+      uint64_t ShiftAmt = SA->getLimitedValue(BitWidth);
+      
+      // Unsigned shift right.
+      APInt Mask2(Mask.shl(ShiftAmt));
+      ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero,KnownOne, TD,
+                        Depth+1);
+      assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); 
+      KnownZero = APIntOps::lshr(KnownZero, ShiftAmt);
+      KnownOne  = APIntOps::lshr(KnownOne, ShiftAmt);
+      // high bits known zero.
+      KnownZero |= APInt::getHighBitsSet(BitWidth, ShiftAmt);
+      return;
+    }
+    break;
+  case Instruction::AShr:
+    // (ashr X, C1) & C2 == 0   iff  (-1 >> C1) & C2 == 0
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      // Compute the new bits that are at the top now.
+      uint64_t ShiftAmt = SA->getLimitedValue(BitWidth);
+      
+      // Signed shift right.
+      APInt Mask2(Mask.shl(ShiftAmt));
+      ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, KnownOne, TD,
+                        Depth+1);
+      assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); 
+      KnownZero = APIntOps::lshr(KnownZero, ShiftAmt);
+      KnownOne  = APIntOps::lshr(KnownOne, ShiftAmt);
+        
+      APInt HighBits(APInt::getHighBitsSet(BitWidth, ShiftAmt));
+      if (KnownZero[BitWidth-ShiftAmt-1])    // New bits are known zero.
+        KnownZero |= HighBits;
+      else if (KnownOne[BitWidth-ShiftAmt-1])  // New bits are known one.
+        KnownOne |= HighBits;
+      return;
+    }
+    break;
+  case Instruction::Sub: {
+    if (ConstantInt *CLHS = dyn_cast<ConstantInt>(I->getOperand(0))) {
+      // We know that the top bits of C-X are clear if X contains less bits
+      // than C (i.e. no wrap-around can happen).  For example, 20-X is
+      // positive if we can prove that X is >= 0 and < 16.
+      if (!CLHS->getValue().isNegative()) {
+        unsigned NLZ = (CLHS->getValue()+1).countLeadingZeros();
+        // NLZ can't be BitWidth with no sign bit
+        APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1);
+        ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero2, KnownOne2,
+                          TD, Depth+1);
+    
+        // If all of the MaskV bits are known to be zero, then we know the
+        // output top bits are zero, because we now know that the output is
+        // from [0-C].
+        if ((KnownZero2 & MaskV) == MaskV) {
+          unsigned NLZ2 = CLHS->getValue().countLeadingZeros();
+          // Top bits known zero.
+          KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask;
+        }
+      }        
+    }
+  }
+  // fall through
+  case Instruction::Add: {
+    // Output known-0 bits are known if clear or set in both the low clear bits
+    // common to both LHS & RHS.  For example, 8+(X<<3) is known to have the
+    // low 3 bits clear.
+    APInt Mask2 = APInt::getLowBitsSet(BitWidth, Mask.countTrailingOnes());
+    ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
+                      Depth+1);
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+    unsigned KnownZeroOut = KnownZero2.countTrailingOnes();
+
+    ComputeMaskedBits(I->getOperand(1), Mask2, KnownZero2, KnownOne2, TD, 
+                      Depth+1);
+    assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); 
+    KnownZeroOut = std::min(KnownZeroOut, 
+                            KnownZero2.countTrailingOnes());
+
+    KnownZero |= APInt::getLowBitsSet(BitWidth, KnownZeroOut);
+    return;
+  }
+  case Instruction::SRem:
+    if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      APInt RA = Rem->getValue();
+      if (RA.isPowerOf2() || (-RA).isPowerOf2()) {
+        APInt LowBits = RA.isStrictlyPositive() ? (RA - 1) : ~RA;
+        APInt Mask2 = LowBits | APInt::getSignBit(BitWidth);
+        ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD, 
+                          Depth+1);
+
+        // The sign of a remainder is equal to the sign of the first
+        // operand (zero being positive).
+        if (KnownZero2[BitWidth-1] || ((KnownZero2 & LowBits) == LowBits))
+          KnownZero2 |= ~LowBits;
+        else if (KnownOne2[BitWidth-1])
+          KnownOne2 |= ~LowBits;
+
+        KnownZero |= KnownZero2 & Mask;
+        KnownOne |= KnownOne2 & Mask;
+
+        assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); 
+      }
+    }
+    break;
+  case Instruction::URem: {
+    if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      APInt RA = Rem->getValue();
+      if (RA.isPowerOf2()) {
+        APInt LowBits = (RA - 1);
+        APInt Mask2 = LowBits & Mask;
+        KnownZero |= ~LowBits & Mask;
+        ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, KnownOne, TD,
+                          Depth+1);
+        assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?");
+        break;
+      }
+    }
+
+    // Since the result is less than or equal to either operand, any leading
+    // zero bits in either operand must also exist in the result.
+    APInt AllOnes = APInt::getAllOnesValue(BitWidth);
+    ComputeMaskedBits(I->getOperand(0), AllOnes, KnownZero, KnownOne,
+                      TD, Depth+1);
+    ComputeMaskedBits(I->getOperand(1), AllOnes, KnownZero2, KnownOne2,
+                      TD, Depth+1);
+
+    uint32_t Leaders = std::max(KnownZero.countLeadingOnes(),
+                                KnownZero2.countLeadingOnes());
+    KnownOne.clear();
+    KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & Mask;
+    break;
+  }
+
+  case Instruction::Alloca:
+  case Instruction::Malloc: {
+    AllocationInst *AI = cast<AllocationInst>(V);
+    unsigned Align = AI->getAlignment();
+    if (Align == 0 && TD) {
+      if (isa<AllocaInst>(AI))
+        Align = TD->getPrefTypeAlignment(AI->getType()->getElementType());
+      else if (isa<MallocInst>(AI)) {
+        // Malloc returns maximally aligned memory.
+        Align = TD->getABITypeAlignment(AI->getType()->getElementType());
+        Align =
+          std::max(Align,
+                   (unsigned)TD->getABITypeAlignment(Type::DoubleTy));
+        Align =
+          std::max(Align,
+                   (unsigned)TD->getABITypeAlignment(Type::Int64Ty));
+      }
+    }
+    
+    if (Align > 0)
+      KnownZero = Mask & APInt::getLowBitsSet(BitWidth,
+                                              CountTrailingZeros_32(Align));
+    break;
+  }
+  case Instruction::GetElementPtr: {
+    // Analyze all of the subscripts of this getelementptr instruction
+    // to determine if we can prove known low zero bits.
+    APInt LocalMask = APInt::getAllOnesValue(BitWidth);
+    APInt LocalKnownZero(BitWidth, 0), LocalKnownOne(BitWidth, 0);
+    ComputeMaskedBits(I->getOperand(0), LocalMask,
+                      LocalKnownZero, LocalKnownOne, TD, Depth+1);
+    unsigned TrailZ = LocalKnownZero.countTrailingOnes();
+
+    gep_type_iterator GTI = gep_type_begin(I);
+    for (unsigned i = 1, e = I->getNumOperands(); i != e; ++i, ++GTI) {
+      Value *Index = I->getOperand(i);
+      if (const StructType *STy = dyn_cast<StructType>(*GTI)) {
+        // Handle struct member offset arithmetic.
+        if (!TD) return;
+        const StructLayout *SL = TD->getStructLayout(STy);
+        unsigned Idx = cast<ConstantInt>(Index)->getZExtValue();
+        uint64_t Offset = SL->getElementOffset(Idx);
+        TrailZ = std::min(TrailZ,
+                          CountTrailingZeros_64(Offset));
+      } else {
+        // Handle array index arithmetic.
+        const Type *IndexedTy = GTI.getIndexedType();
+        if (!IndexedTy->isSized()) return;
+        unsigned GEPOpiBits = Index->getType()->getPrimitiveSizeInBits();
+        uint64_t TypeSize = TD ? TD->getABITypeSize(IndexedTy) : 1;
+        LocalMask = APInt::getAllOnesValue(GEPOpiBits);
+        LocalKnownZero = LocalKnownOne = APInt(GEPOpiBits, 0);
+        ComputeMaskedBits(Index, LocalMask,
+                          LocalKnownZero, LocalKnownOne, TD, Depth+1);
+        TrailZ = std::min(TrailZ,
+                          CountTrailingZeros_64(TypeSize) +
+                            LocalKnownZero.countTrailingOnes());
+      }
+    }
+    
+    KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) & Mask;
+    break;
+  }
+  case Instruction::PHI: {
+    PHINode *P = cast<PHINode>(I);
+    // Handle the case of a simple two-predecessor recurrence PHI.
+    // There's a lot more that could theoretically be done here, but
+    // this is sufficient to catch some interesting cases.
+    if (P->getNumIncomingValues() == 2) {
+      for (unsigned i = 0; i != 2; ++i) {
+        Value *L = P->getIncomingValue(i);
+        Value *R = P->getIncomingValue(!i);
+        User *LU = dyn_cast<User>(L);
+        if (!LU)
+          continue;
+        unsigned Opcode = getOpcode(LU);
+        // Check for operations that have the property that if
+        // both their operands have low zero bits, the result
+        // will have low zero bits.
+        if (Opcode == Instruction::Add ||
+            Opcode == Instruction::Sub ||
+            Opcode == Instruction::And ||
+            Opcode == Instruction::Or ||
+            Opcode == Instruction::Mul) {
+          Value *LL = LU->getOperand(0);
+          Value *LR = LU->getOperand(1);
+          // Find a recurrence.
+          if (LL == I)
+            L = LR;
+          else if (LR == I)
+            L = LL;
+          else
+            break;
+          // Ok, we have a PHI of the form L op= R. Check for low
+          // zero bits.
+          APInt Mask2 = APInt::getAllOnesValue(BitWidth);
+          ComputeMaskedBits(R, Mask2, KnownZero2, KnownOne2, TD, Depth+1);
+          Mask2 = APInt::getLowBitsSet(BitWidth,
+                                       KnownZero2.countTrailingOnes());
+          KnownOne2.clear();
+          KnownZero2.clear();
+          ComputeMaskedBits(L, Mask2, KnownZero2, KnownOne2, TD, Depth+1);
+          KnownZero = Mask &
+                      APInt::getLowBitsSet(BitWidth,
+                                           KnownZero2.countTrailingOnes());
+          break;
+        }
+      }
+    }
+    break;
+  }
+  case Instruction::Call:
+    if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
+      switch (II->getIntrinsicID()) {
+      default: break;
+      case Intrinsic::ctpop:
+      case Intrinsic::ctlz:
+      case Intrinsic::cttz: {
+        unsigned LowBits = Log2_32(BitWidth)+1;
+        KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - LowBits);
+        break;
+      }
+      }
+    }
+    break;
+  }
+}
+
+/// MaskedValueIsZero - Return true if 'V & Mask' is known to be zero.  We use
+/// this predicate to simplify operations downstream.  Mask is known to be zero
+/// for bits that V cannot have.
+bool llvm::MaskedValueIsZero(Value *V, const APInt &Mask,
+                             TargetData *TD, unsigned Depth) {
+  APInt KnownZero(Mask.getBitWidth(), 0), KnownOne(Mask.getBitWidth(), 0);
+  ComputeMaskedBits(V, Mask, KnownZero, KnownOne, TD, Depth);
+  assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
+  return (KnownZero & Mask) == Mask;
+}
+
+
+
+/// ComputeNumSignBits - Return the number of times the sign bit of the
+/// register is replicated into the other bits.  We know that at least 1 bit
+/// is always equal to the sign bit (itself), but other cases can give us
+/// information.  For example, immediately after an "ashr X, 2", we know that
+/// the top 3 bits are all equal to each other, so we return 3.
+///
+/// 'Op' must have a scalar integer type.
+///
+unsigned llvm::ComputeNumSignBits(Value *V, TargetData *TD, unsigned Depth) {
+  const IntegerType *Ty = cast<IntegerType>(V->getType());
+  unsigned TyBits = Ty->getBitWidth();
+  unsigned Tmp, Tmp2;
+  unsigned FirstAnswer = 1;
+
+  // Note that ConstantInt is handled by the general ComputeMaskedBits case
+  // below.
+
+  if (Depth == 6)
+    return 1;  // Limit search depth.
+  
+  User *U = dyn_cast<User>(V);
+  switch (getOpcode(V)) {
+  default: break;
+  case Instruction::SExt:
+    Tmp = TyBits-cast<IntegerType>(U->getOperand(0)->getType())->getBitWidth();
+    return ComputeNumSignBits(U->getOperand(0), TD, Depth+1) + Tmp;
+    
+  case Instruction::AShr:
+    Tmp = ComputeNumSignBits(U->getOperand(0), TD, Depth+1);
+    // ashr X, C   -> adds C sign bits.
+    if (ConstantInt *C = dyn_cast<ConstantInt>(U->getOperand(1))) {
+      Tmp += C->getZExtValue();
+      if (Tmp > TyBits) Tmp = TyBits;
+    }
+    return Tmp;
+  case Instruction::Shl:
+    if (ConstantInt *C = dyn_cast<ConstantInt>(U->getOperand(1))) {
+      // shl destroys sign bits.
+      Tmp = ComputeNumSignBits(U->getOperand(0), TD, Depth+1);
+      if (C->getZExtValue() >= TyBits ||      // Bad shift.
+          C->getZExtValue() >= Tmp) break;    // Shifted all sign bits out.
+      return Tmp - C->getZExtValue();
+    }
+    break;
+  case Instruction::And:
+  case Instruction::Or:
+  case Instruction::Xor:    // NOT is handled here.
+    // Logical binary ops preserve the number of sign bits at the worst.
+    Tmp = ComputeNumSignBits(U->getOperand(0), TD, Depth+1);
+    if (Tmp != 1) {
+      Tmp2 = ComputeNumSignBits(U->getOperand(1), TD, Depth+1);
+      FirstAnswer = std::min(Tmp, Tmp2);
+      // We computed what we know about the sign bits as our first
+      // answer. Now proceed to the generic code that uses
+      // ComputeMaskedBits, and pick whichever answer is better.
+    }
+    break;
+
+  case Instruction::Select:
+    Tmp = ComputeNumSignBits(U->getOperand(1), TD, Depth+1);
+    if (Tmp == 1) return 1;  // Early out.
+    Tmp2 = ComputeNumSignBits(U->getOperand(2), TD, Depth+1);
+    return std::min(Tmp, Tmp2);
+    
+  case Instruction::Add:
+    // Add can have at most one carry bit.  Thus we know that the output
+    // is, at worst, one more bit than the inputs.
+    Tmp = ComputeNumSignBits(U->getOperand(0), TD, Depth+1);
+    if (Tmp == 1) return 1;  // Early out.
+      
+    // Special case decrementing a value (ADD X, -1):
+    if (ConstantInt *CRHS = dyn_cast<ConstantInt>(U->getOperand(0)))
+      if (CRHS->isAllOnesValue()) {
+        APInt KnownZero(TyBits, 0), KnownOne(TyBits, 0);
+        APInt Mask = APInt::getAllOnesValue(TyBits);
+        ComputeMaskedBits(U->getOperand(0), Mask, KnownZero, KnownOne, TD,
+                          Depth+1);
+        
+        // If the input is known to be 0 or 1, the output is 0/-1, which is all
+        // sign bits set.
+        if ((KnownZero | APInt(TyBits, 1)) == Mask)
+          return TyBits;
+        
+        // If we are subtracting one from a positive number, there is no carry
+        // out of the result.
+        if (KnownZero.isNegative())
+          return Tmp;
+      }
+      
+    Tmp2 = ComputeNumSignBits(U->getOperand(1), TD, Depth+1);
+    if (Tmp2 == 1) return 1;
+      return std::min(Tmp, Tmp2)-1;
+    break;
+    
+  case Instruction::Sub:
+    Tmp2 = ComputeNumSignBits(U->getOperand(1), TD, Depth+1);
+    if (Tmp2 == 1) return 1;
+      
+    // Handle NEG.
+    if (ConstantInt *CLHS = dyn_cast<ConstantInt>(U->getOperand(0)))
+      if (CLHS->isNullValue()) {
+        APInt KnownZero(TyBits, 0), KnownOne(TyBits, 0);
+        APInt Mask = APInt::getAllOnesValue(TyBits);
+        ComputeMaskedBits(U->getOperand(1), Mask, KnownZero, KnownOne, 
+                          TD, Depth+1);
+        // If the input is known to be 0 or 1, the output is 0/-1, which is all
+        // sign bits set.
+        if ((KnownZero | APInt(TyBits, 1)) == Mask)
+          return TyBits;
+        
+        // If the input is known to be positive (the sign bit is known clear),
+        // the output of the NEG has the same number of sign bits as the input.
+        if (KnownZero.isNegative())
+          return Tmp2;
+        
+        // Otherwise, we treat this like a SUB.
+      }
+    
+    // Sub can have at most one carry bit.  Thus we know that the output
+    // is, at worst, one more bit than the inputs.
+    Tmp = ComputeNumSignBits(U->getOperand(0), TD, Depth+1);
+    if (Tmp == 1) return 1;  // Early out.
+      return std::min(Tmp, Tmp2)-1;
+    break;
+  case Instruction::Trunc:
+    // FIXME: it's tricky to do anything useful for this, but it is an important
+    // case for targets like X86.
+    break;
+  }
+  
+  // Finally, if we can prove that the top bits of the result are 0's or 1's,
+  // use this information.
+  APInt KnownZero(TyBits, 0), KnownOne(TyBits, 0);
+  APInt Mask = APInt::getAllOnesValue(TyBits);
+  ComputeMaskedBits(V, Mask, KnownZero, KnownOne, TD, Depth);
+  
+  if (KnownZero.isNegative()) {        // sign bit is 0
+    Mask = KnownZero;
+  } else if (KnownOne.isNegative()) {  // sign bit is 1;
+    Mask = KnownOne;
+  } else {
+    // Nothing known.
+    return FirstAnswer;
+  }
+  
+  // Okay, we know that the sign bit in Mask is set.  Use CLZ to determine
+  // the number of identical bits in the top of the input value.
+  Mask = ~Mask;
+  Mask <<= Mask.getBitWidth()-TyBits;
+  // Return # leading zeros.  We use 'min' here in case Val was zero before
+  // shifting.  We don't want to return '64' as for an i32 "0".
+  return std::max(FirstAnswer, std::min(TyBits, Mask.countLeadingZeros()));
+}
+
+/// CannotBeNegativeZero - Return true if we can prove that the specified FP 
+/// value is never equal to -0.0.
+///
+/// NOTE: this function will need to be revisited when we support non-default
+/// rounding modes!
+///
+bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
+  if (const ConstantFP *CFP = dyn_cast<ConstantFP>(V))
+    return !CFP->getValueAPF().isNegZero();
+  
+  if (Depth == 6)
+    return 1;  // Limit search depth.
+
+  const Instruction *I = dyn_cast<Instruction>(V);
+  if (I == 0) return false;
+  
+  // (add x, 0.0) is guaranteed to return +0.0, not -0.0.
+  if (I->getOpcode() == Instruction::Add &&
+      isa<ConstantFP>(I->getOperand(1)) && 
+      cast<ConstantFP>(I->getOperand(1))->isNullValue())
+    return true;
+    
+  // sitofp and uitofp turn into +0.0 for zero.
+  if (isa<SIToFPInst>(I) || isa<UIToFPInst>(I))
+    return true;
+  
+  if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
+    // sqrt(-0.0) = -0.0, no other negative results are possible.
+    if (II->getIntrinsicID() == Intrinsic::sqrt)
+      return CannotBeNegativeZero(II->getOperand(1), Depth+1);
+  
+  if (const CallInst *CI = dyn_cast<CallInst>(I))
+    if (const Function *F = CI->getCalledFunction()) {
+      if (F->isDeclaration()) {
+        switch (F->getNameLen()) {
+        case 3:  // abs(x) != -0.0
+          if (!strcmp(F->getNameStart(), "abs")) return true;
+          break;
+        case 4:  // abs[lf](x) != -0.0
+          if (!strcmp(F->getNameStart(), "absf")) return true;
+          if (!strcmp(F->getNameStart(), "absl")) return true;
+          break;
+        }
+      }
+    }
+  
+  return false;
+}
+
+// This is the recursive version of BuildSubAggregate. It takes a few different
+// arguments. Idxs is the index within the nested struct From that we are
+// looking at now (which is of type IndexedType). IdxSkip is the number of
+// indices from Idxs that should be left out when inserting into the resulting
+// struct. To is the result struct built so far, new insertvalue instructions
+// build on that.
+Value *BuildSubAggregate(Value *From, Value* To, const Type *IndexedType,
+                                 SmallVector<unsigned, 10> &Idxs,
+                                 unsigned IdxSkip,
+                                 Instruction *InsertBefore) {
+  const llvm::StructType *STy = llvm::dyn_cast<llvm::StructType>(IndexedType);
+  if (STy) {
+    // Save the original To argument so we can modify it
+    Value *OrigTo = To;
+    // General case, the type indexed by Idxs is a struct
+    for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+      // Process each struct element recursively
+      Idxs.push_back(i);
+      Value *PrevTo = To;
+      To = BuildSubAggregate(From, To, STy->getElementType(i), Idxs, IdxSkip,
+                             InsertBefore);
+      Idxs.pop_back();
+      if (!To) {
+        // Couldn't find any inserted value for this index? Cleanup
+        while (PrevTo != OrigTo) {
+          InsertValueInst* Del = cast<InsertValueInst>(PrevTo);
+          PrevTo = Del->getAggregateOperand();
+          Del->eraseFromParent();
+        }
+        // Stop processing elements
+        break;
+      }
+    }
+    // If we succesfully found a value for each of our subaggregates 
+    if (To)
+      return To;
+  }
+  // Base case, the type indexed by SourceIdxs is not a struct, or not all of
+  // the struct's elements had a value that was inserted directly. In the latter
+  // case, perhaps we can't determine each of the subelements individually, but
+  // we might be able to find the complete struct somewhere.
+  
+  // Find the value that is at that particular spot
+  Value *V = FindInsertedValue(From, Idxs.begin(), Idxs.end());
+
+  if (!V)
+    return NULL;
+
+  // Insert the value in the new (sub) aggregrate
+  return llvm::InsertValueInst::Create(To, V, Idxs.begin() + IdxSkip,
+                                       Idxs.end(), "tmp", InsertBefore);
+}
+
+// This helper takes a nested struct and extracts a part of it (which is again a
+// struct) into a new value. For example, given the struct:
+// { a, { b, { c, d }, e } }
+// and the indices "1, 1" this returns
+// { c, d }.
+//
+// It does this by inserting an insertvalue for each element in the resulting
+// struct, as opposed to just inserting a single struct. This will only work if
+// each of the elements of the substruct are known (ie, inserted into From by an
+// insertvalue instruction somewhere).
+//
+// All inserted insertvalue instructions are inserted before InsertBefore
+Value *BuildSubAggregate(Value *From, const unsigned *idx_begin,
+                         const unsigned *idx_end, Instruction *InsertBefore) {
+  assert(InsertBefore && "Must have someplace to insert!");
+  const Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(),
+                                                             idx_begin,
+                                                             idx_end);
+  Value *To = UndefValue::get(IndexedType);
+  SmallVector<unsigned, 10> Idxs(idx_begin, idx_end);
+  unsigned IdxSkip = Idxs.size();
+
+  return BuildSubAggregate(From, To, IndexedType, Idxs, IdxSkip, InsertBefore);
+}
+
+/// FindInsertedValue - Given an aggregrate and an sequence of indices, see if
+/// the scalar value indexed is already around as a register, for example if it
+/// were inserted directly into the aggregrate.
+///
+/// If InsertBefore is not null, this function will duplicate (modified)
+/// insertvalues when a part of a nested struct is extracted.
+Value *llvm::FindInsertedValue(Value *V, const unsigned *idx_begin,
+                         const unsigned *idx_end, Instruction *InsertBefore) {
+  // Nothing to index? Just return V then (this is useful at the end of our
+  // recursion)
+  if (idx_begin == idx_end)
+    return V;
+  // We have indices, so V should have an indexable type
+  assert((isa<StructType>(V->getType()) || isa<ArrayType>(V->getType()))
+         && "Not looking at a struct or array?");
+  assert(ExtractValueInst::getIndexedType(V->getType(), idx_begin, idx_end)
+         && "Invalid indices for type?");
+  const CompositeType *PTy = cast<CompositeType>(V->getType());
+  
+  if (isa<UndefValue>(V))
+    return UndefValue::get(ExtractValueInst::getIndexedType(PTy,
+                                                              idx_begin,
+                                                              idx_end));
+  else if (isa<ConstantAggregateZero>(V))
+    return Constant::getNullValue(ExtractValueInst::getIndexedType(PTy, 
+                                                                     idx_begin,
+                                                                     idx_end));
+  else if (Constant *C = dyn_cast<Constant>(V)) {
+    if (isa<ConstantArray>(C) || isa<ConstantStruct>(C))
+      // Recursively process this constant
+      return FindInsertedValue(C->getOperand(*idx_begin), ++idx_begin, idx_end,
+                               InsertBefore);
+  } else if (InsertValueInst *I = dyn_cast<InsertValueInst>(V)) {
+    // Loop the indices for the insertvalue instruction in parallel with the
+    // requested indices
+    const unsigned *req_idx = idx_begin;
+    for (const unsigned *i = I->idx_begin(), *e = I->idx_end();
+         i != e; ++i, ++req_idx) {
+      if (req_idx == idx_end) {
+        if (InsertBefore)
+          // The requested index identifies a part of a nested aggregate. Handle
+          // this specially. For example,
+          // %A = insertvalue { i32, {i32, i32 } } undef, i32 10, 1, 0
+          // %B = insertvalue { i32, {i32, i32 } } %A, i32 11, 1, 1
+          // %C = extractvalue {i32, { i32, i32 } } %B, 1
+          // This can be changed into
+          // %A = insertvalue {i32, i32 } undef, i32 10, 0
+          // %C = insertvalue {i32, i32 } %A, i32 11, 1
+          // which allows the unused 0,0 element from the nested struct to be
+          // removed.
+          return BuildSubAggregate(V, idx_begin, req_idx, InsertBefore);
+        else
+          // We can't handle this without inserting insertvalues
+          return 0;
+      }
+      
+      // This insert value inserts something else than what we are looking for.
+      // See if the (aggregrate) value inserted into has the value we are
+      // looking for, then.
+      if (*req_idx != *i)
+        return FindInsertedValue(I->getAggregateOperand(), idx_begin, idx_end,
+                                 InsertBefore);
+    }
+    // If we end up here, the indices of the insertvalue match with those
+    // requested (though possibly only partially). Now we recursively look at
+    // the inserted value, passing any remaining indices.
+    return FindInsertedValue(I->getInsertedValueOperand(), req_idx, idx_end,
+                             InsertBefore);
+  } else if (ExtractValueInst *I = dyn_cast<ExtractValueInst>(V)) {
+    // If we're extracting a value from an aggregrate that was extracted from
+    // something else, we can extract from that something else directly instead.
+    // However, we will need to chain I's indices with the requested indices.
+   
+    // Calculate the number of indices required 
+    unsigned size = I->getNumIndices() + (idx_end - idx_begin);
+    // Allocate some space to put the new indices in
+    SmallVector<unsigned, 5> Idxs;
+    Idxs.reserve(size);
+    // Add indices from the extract value instruction
+    for (const unsigned *i = I->idx_begin(), *e = I->idx_end();
+         i != e; ++i)
+      Idxs.push_back(*i);
+    
+    // Add requested indices
+    for (const unsigned *i = idx_begin, *e = idx_end; i != e; ++i)
+      Idxs.push_back(*i);
+
+    assert(Idxs.size() == size 
+           && "Number of indices added not correct?");
+    
+    return FindInsertedValue(I->getAggregateOperand(), Idxs.begin(), Idxs.end(),
+                             InsertBefore);
+  }
+  // Otherwise, we don't know (such as, extracting from a function return value
+  // or load instruction)
+  return 0;
+}
+
+/// GetConstantStringInfo - This function computes the length of a
+/// null-terminated C string pointed to by V.  If successful, it returns true
+/// and returns the string in Str.  If unsuccessful, it returns false.
+bool llvm::GetConstantStringInfo(Value *V, std::string &Str, uint64_t Offset,
+                                 bool StopAtNul) {
+  // If V is NULL then return false;
+  if (V == NULL) return false;
+
+  // Look through bitcast instructions.
+  if (BitCastInst *BCI = dyn_cast<BitCastInst>(V))
+    return GetConstantStringInfo(BCI->getOperand(0), Str, Offset, StopAtNul);
+  
+  // If the value is not a GEP instruction nor a constant expression with a
+  // GEP instruction, then return false because ConstantArray can't occur
+  // any other way
+  User *GEP = 0;
+  if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(V)) {
+    GEP = GEPI;
+  } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
+    if (CE->getOpcode() == Instruction::BitCast)
+      return GetConstantStringInfo(CE->getOperand(0), Str, Offset, StopAtNul);
+    if (CE->getOpcode() != Instruction::GetElementPtr)
+      return false;
+    GEP = CE;
+  }
+  
+  if (GEP) {
+    // Make sure the GEP has exactly three arguments.
+    if (GEP->getNumOperands() != 3)
+      return false;
+    
+    // Make sure the index-ee is a pointer to array of i8.
+    const PointerType *PT = cast<PointerType>(GEP->getOperand(0)->getType());
+    const ArrayType *AT = dyn_cast<ArrayType>(PT->getElementType());
+    if (AT == 0 || AT->getElementType() != Type::Int8Ty)
+      return false;
+    
+    // Check to make sure that the first operand of the GEP is an integer and
+    // has value 0 so that we are sure we're indexing into the initializer.
+    ConstantInt *FirstIdx = dyn_cast<ConstantInt>(GEP->getOperand(1));
+    if (FirstIdx == 0 || !FirstIdx->isZero())
+      return false;
+    
+    // If the second index isn't a ConstantInt, then this is a variable index
+    // into the array.  If this occurs, we can't say anything meaningful about
+    // the string.
+    uint64_t StartIdx = 0;
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(GEP->getOperand(2)))
+      StartIdx = CI->getZExtValue();
+    else
+      return false;
+    return GetConstantStringInfo(GEP->getOperand(0), Str, StartIdx+Offset,
+                                 StopAtNul);
+  }
+  
+  // The GEP instruction, constant or instruction, must reference a global
+  // variable that is a constant and is initialized. The referenced constant
+  // initializer is the array that we'll use for optimization.
+  GlobalVariable* GV = dyn_cast<GlobalVariable>(V);
+  if (!GV || !GV->isConstant() || !GV->hasInitializer())
+    return false;
+  Constant *GlobalInit = GV->getInitializer();
+  
+  // Handle the ConstantAggregateZero case
+  if (isa<ConstantAggregateZero>(GlobalInit)) {
+    // This is a degenerate case. The initializer is constant zero so the
+    // length of the string must be zero.
+    Str.clear();
+    return true;
+  }
+  
+  // Must be a Constant Array
+  ConstantArray *Array = dyn_cast<ConstantArray>(GlobalInit);
+  if (Array == 0 || Array->getType()->getElementType() != Type::Int8Ty)
+    return false;
+  
+  // Get the number of elements in the array
+  uint64_t NumElts = Array->getType()->getNumElements();
+  
+  if (Offset > NumElts)
+    return false;
+  
+  // Traverse the constant array from 'Offset' which is the place the GEP refers
+  // to in the array.
+  Str.reserve(NumElts-Offset);
+  for (unsigned i = Offset; i != NumElts; ++i) {
+    Constant *Elt = Array->getOperand(i);
+    ConstantInt *CI = dyn_cast<ConstantInt>(Elt);
+    if (!CI) // This array isn't suitable, non-int initializer.
+      return false;
+    if (StopAtNul && CI->isZero())
+      return true; // we found end of string, success!
+    Str += (char)CI->getZExtValue();
+  }
+  
+  // The array isn't null terminated, but maybe this is a memcpy, not a strcpy.
+  return true;
+}

Modified: llvm/branches/non-call-eh/lib/Archive/ArchiveReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Archive/ArchiveReader.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Archive/ArchiveReader.cpp (original)
+++ llvm/branches/non-call-eh/lib/Archive/ArchiveReader.cpp Sun Jul  6 15:45:41 2008
@@ -19,7 +19,7 @@
 using namespace llvm;
 
 /// Read a variable-bit-rate encoded unsigned integer
-inline unsigned readInteger(const char*&At, const char*End){
+static inline unsigned readInteger(const char*&At, const char*End) {
   unsigned Shift = 0;
   unsigned Result = 0;
 

Modified: llvm/branches/non-call-eh/lib/Archive/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Archive/ArchiveWriter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Archive/ArchiveWriter.cpp (original)
+++ llvm/branches/non-call-eh/lib/Archive/ArchiveWriter.cpp Sun Jul  6 15:45:41 2008
@@ -25,7 +25,7 @@
 
 // Write an integer using variable bit rate encoding. This saves a few bytes
 // per entry in the symbol table.
-inline void writeInteger(unsigned num, std::ofstream& ARFile) {
+static inline void writeInteger(unsigned num, std::ofstream& ARFile) {
   while (1) {
     if (num < 0x80) { // done?
       ARFile << (unsigned char)num;
@@ -41,7 +41,7 @@
 
 // Compute how many bytes are taken by a given VBR encoded value. This is needed
 // to pre-compute the size of the symbol table.
-inline unsigned numVbrBytes(unsigned num) {
+static inline unsigned numVbrBytes(unsigned num) {
 
   // Note that the following nested ifs are somewhat equivalent to a binary
   // search. We split it in half by comparing against 2^14 first. This allows
@@ -467,5 +467,12 @@
   if (TmpArchive.renamePathOnDisk(archPath, ErrMsg))
     return true;
 
+  // Set correct read and write permissions after temporary file is moved
+  // to final destination path.
+  if (archPath.makeReadableOnDisk(ErrMsg))
+    return true;
+  if (archPath.makeWriteableOnDisk(ErrMsg))
+    return true;
+
   return false;
 }

Modified: llvm/branches/non-call-eh/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/AsmParser/LLLexer.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/branches/non-call-eh/lib/AsmParser/LLLexer.cpp Sun Jul  6 15:45:41 2008
@@ -451,6 +451,8 @@
   KEYWORD("appending", APPENDING);
   KEYWORD("dllimport", DLLIMPORT);
   KEYWORD("dllexport", DLLEXPORT);
+  KEYWORD("common", COMMON);
+  KEYWORD("default", DEFAULT);
   KEYWORD("hidden", HIDDEN);
   KEYWORD("protected", PROTECTED);
   KEYWORD("extern_weak", EXTERN_WEAK);
@@ -474,7 +476,6 @@
   KEYWORD("asm", ASM_TOK);
   KEYWORD("sideeffect", SIDEEFFECT);
   KEYWORD("gc", GC);
-  KEYWORD("unwinds", UNWINDS);
 
   KEYWORD("cc", CC_TOK);
   KEYWORD("ccc", CCC_TOK);
@@ -567,6 +568,8 @@
   INSTKEYWORD("xor",     BinaryOpVal, Xor, XOR);
   INSTKEYWORD("icmp",    OtherOpVal,  ICmp,  ICMP);
   INSTKEYWORD("fcmp",    OtherOpVal,  FCmp,  FCMP);
+  INSTKEYWORD("vicmp",   OtherOpVal,  VICmp, VICMP);
+  INSTKEYWORD("vfcmp",   OtherOpVal,  VFCmp, VFCMP);
 
   INSTKEYWORD("phi",         OtherOpVal, PHI, PHI_TOK);
   INSTKEYWORD("call",        OtherOpVal, Call, CALL);
@@ -602,6 +605,8 @@
   INSTKEYWORD("insertelement", OtherOpVal, InsertElement, INSERTELEMENT);
   INSTKEYWORD("shufflevector", OtherOpVal, ShuffleVector, SHUFFLEVECTOR);
   INSTKEYWORD("getresult", OtherOpVal, GetResult, GETRESULT);
+  INSTKEYWORD("extractvalue", OtherOpVal, ExtractValue, EXTRACTVALUE);
+  INSTKEYWORD("insertvalue", OtherOpVal, InsertValue, INSERTVALUE);
 #undef INSTKEYWORD
 
   // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by

Modified: llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.cpp.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.cpp.cvs?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.cpp.cvs (original)
+++ llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.cpp.cvs Sun Jul  6 15:45:41 2008
@@ -120,26 +120,26 @@
      DLLIMPORT = 301,
      DLLEXPORT = 302,
      EXTERN_WEAK = 303,
-     OPAQUE = 304,
-     EXTERNAL = 305,
-     TARGET = 306,
-     TRIPLE = 307,
-     ALIGN = 308,
-     ADDRSPACE = 309,
-     DEPLIBS = 310,
-     CALL = 311,
-     TAIL = 312,
-     ASM_TOK = 313,
-     MODULE = 314,
-     SIDEEFFECT = 315,
-     CC_TOK = 316,
-     CCC_TOK = 317,
-     FASTCC_TOK = 318,
-     COLDCC_TOK = 319,
-     X86_STDCALLCC_TOK = 320,
-     X86_FASTCALLCC_TOK = 321,
-     DATALAYOUT = 322,
-     UNWINDS = 323,
+     COMMON = 304,
+     OPAQUE = 305,
+     EXTERNAL = 306,
+     TARGET = 307,
+     TRIPLE = 308,
+     ALIGN = 309,
+     ADDRSPACE = 310,
+     DEPLIBS = 311,
+     CALL = 312,
+     TAIL = 313,
+     ASM_TOK = 314,
+     MODULE = 315,
+     SIDEEFFECT = 316,
+     CC_TOK = 317,
+     CCC_TOK = 318,
+     FASTCC_TOK = 319,
+     COLDCC_TOK = 320,
+     X86_STDCALLCC_TOK = 321,
+     X86_FASTCALLCC_TOK = 322,
+     DATALAYOUT = 323,
      RET = 324,
      BR = 325,
      SWITCH = 326,
@@ -163,66 +163,70 @@
      ASHR = 344,
      ICMP = 345,
      FCMP = 346,
-     EQ = 347,
-     NE = 348,
-     SLT = 349,
-     SGT = 350,
-     SLE = 351,
-     SGE = 352,
-     ULT = 353,
-     UGT = 354,
-     ULE = 355,
-     UGE = 356,
-     OEQ = 357,
-     ONE = 358,
-     OLT = 359,
-     OGT = 360,
-     OLE = 361,
-     OGE = 362,
-     ORD = 363,
-     UNO = 364,
-     UEQ = 365,
-     UNE = 366,
-     MALLOC = 367,
-     ALLOCA = 368,
-     FREE = 369,
-     LOAD = 370,
-     STORE = 371,
-     GETELEMENTPTR = 372,
-     TRUNC = 373,
-     ZEXT = 374,
-     SEXT = 375,
-     FPTRUNC = 376,
-     FPEXT = 377,
-     BITCAST = 378,
-     UITOFP = 379,
-     SITOFP = 380,
-     FPTOUI = 381,
-     FPTOSI = 382,
-     INTTOPTR = 383,
-     PTRTOINT = 384,
-     PHI_TOK = 385,
-     SELECT = 386,
-     VAARG = 387,
-     EXTRACTELEMENT = 388,
-     INSERTELEMENT = 389,
-     SHUFFLEVECTOR = 390,
-     GETRESULT = 391,
-     SIGNEXT = 392,
-     ZEROEXT = 393,
-     NORETURN = 394,
-     INREG = 395,
-     SRET = 396,
-     NOUNWIND = 397,
-     NOALIAS = 398,
-     BYVAL = 399,
-     NEST = 400,
-     READNONE = 401,
-     READONLY = 402,
-     GC = 403,
-     DEFAULT = 404,
-     HIDDEN = 405,
-     PROTECTED = 406
+     VICMP = 347,
+     VFCMP = 348,
+     EQ = 349,
+     NE = 350,
+     SLT = 351,
+     SGT = 352,
+     SLE = 353,
+     SGE = 354,
+     ULT = 355,
+     UGT = 356,
+     ULE = 357,
+     UGE = 358,
+     OEQ = 359,
+     ONE = 360,
+     OLT = 361,
+     OGT = 362,
+     OLE = 363,
+     OGE = 364,
+     ORD = 365,
+     UNO = 366,
+     UEQ = 367,
+     UNE = 368,
+     MALLOC = 369,
+     ALLOCA = 370,
+     FREE = 371,
+     LOAD = 372,
+     STORE = 373,
+     GETELEMENTPTR = 374,
+     TRUNC = 375,
+     ZEXT = 376,
+     SEXT = 377,
+     FPTRUNC = 378,
+     FPEXT = 379,
+     BITCAST = 380,
+     UITOFP = 381,
+     SITOFP = 382,
+     FPTOUI = 383,
+     FPTOSI = 384,
+     INTTOPTR = 385,
+     PTRTOINT = 386,
+     PHI_TOK = 387,
+     SELECT = 388,
+     VAARG = 389,
+     EXTRACTELEMENT = 390,
+     INSERTELEMENT = 391,
+     SHUFFLEVECTOR = 392,
+     GETRESULT = 393,
+     EXTRACTVALUE = 394,
+     INSERTVALUE = 395,
+     SIGNEXT = 396,
+     ZEROEXT = 397,
+     NORETURN = 398,
+     INREG = 399,
+     SRET = 400,
+     NOUNWIND = 401,
+     NOALIAS = 402,
+     BYVAL = 403,
+     NEST = 404,
+     READNONE = 405,
+     READONLY = 406,
+     GC = 407,
+     DEFAULT = 408,
+     HIDDEN = 409,
+     PROTECTED = 410
    };
 #endif
 /* Tokens.  */
@@ -272,26 +276,26 @@
 #define DLLIMPORT 301
 #define DLLEXPORT 302
 #define EXTERN_WEAK 303
-#define OPAQUE 304
-#define EXTERNAL 305
-#define TARGET 306
-#define TRIPLE 307
-#define ALIGN 308
-#define ADDRSPACE 309
-#define DEPLIBS 310
-#define CALL 311
-#define TAIL 312
-#define ASM_TOK 313
-#define MODULE 314
-#define SIDEEFFECT 315
-#define CC_TOK 316
-#define CCC_TOK 317
-#define FASTCC_TOK 318
-#define COLDCC_TOK 319
-#define X86_STDCALLCC_TOK 320
-#define X86_FASTCALLCC_TOK 321
-#define DATALAYOUT 322
-#define UNWINDS 323
+#define COMMON 304
+#define OPAQUE 305
+#define EXTERNAL 306
+#define TARGET 307
+#define TRIPLE 308
+#define ALIGN 309
+#define ADDRSPACE 310
+#define DEPLIBS 311
+#define CALL 312
+#define TAIL 313
+#define ASM_TOK 314
+#define MODULE 315
+#define SIDEEFFECT 316
+#define CC_TOK 317
+#define CCC_TOK 318
+#define FASTCC_TOK 319
+#define COLDCC_TOK 320
+#define X86_STDCALLCC_TOK 321
+#define X86_FASTCALLCC_TOK 322
+#define DATALAYOUT 323
 #define RET 324
 #define BR 325
 #define SWITCH 326
@@ -315,72 +319,76 @@
 #define ASHR 344
 #define ICMP 345
 #define FCMP 346
-#define EQ 347
-#define NE 348
-#define SLT 349
-#define SGT 350
-#define SLE 351
-#define SGE 352
-#define ULT 353
-#define UGT 354
-#define ULE 355
-#define UGE 356
-#define OEQ 357
-#define ONE 358
-#define OLT 359
-#define OGT 360
-#define OLE 361
-#define OGE 362
-#define ORD 363
-#define UNO 364
-#define UEQ 365
-#define UNE 366
-#define MALLOC 367
-#define ALLOCA 368
-#define FREE 369
-#define LOAD 370
-#define STORE 371
-#define GETELEMENTPTR 372
-#define TRUNC 373
-#define ZEXT 374
-#define SEXT 375
-#define FPTRUNC 376
-#define FPEXT 377
-#define BITCAST 378
-#define UITOFP 379
-#define SITOFP 380
-#define FPTOUI 381
-#define FPTOSI 382
-#define INTTOPTR 383
-#define PTRTOINT 384
-#define PHI_TOK 385
-#define SELECT 386
-#define VAARG 387
-#define EXTRACTELEMENT 388
-#define INSERTELEMENT 389
-#define SHUFFLEVECTOR 390
-#define GETRESULT 391
-#define SIGNEXT 392
-#define ZEROEXT 393
-#define NORETURN 394
-#define INREG 395
-#define SRET 396
-#define NOUNWIND 397
-#define NOALIAS 398
-#define BYVAL 399
-#define NEST 400
-#define READNONE 401
-#define READONLY 402
-#define GC 403
-#define DEFAULT 404
-#define HIDDEN 405
-#define PROTECTED 406
+#define VICMP 347
+#define VFCMP 348
+#define EQ 349
+#define NE 350
+#define SLT 351
+#define SGT 352
+#define SLE 353
+#define SGE 354
+#define ULT 355
+#define UGT 356
+#define ULE 357
+#define UGE 358
+#define OEQ 359
+#define ONE 360
+#define OLT 361
+#define OGT 362
+#define OLE 363
+#define OGE 364
+#define ORD 365
+#define UNO 366
+#define UEQ 367
+#define UNE 368
+#define MALLOC 369
+#define ALLOCA 370
+#define FREE 371
+#define LOAD 372
+#define STORE 373
+#define GETELEMENTPTR 374
+#define TRUNC 375
+#define ZEXT 376
+#define SEXT 377
+#define FPTRUNC 378
+#define FPEXT 379
+#define BITCAST 380
+#define UITOFP 381
+#define SITOFP 382
+#define FPTOUI 383
+#define FPTOSI 384
+#define INTTOPTR 385
+#define PTRTOINT 386
+#define PHI_TOK 387
+#define SELECT 388
+#define VAARG 389
+#define EXTRACTELEMENT 390
+#define INSERTELEMENT 391
+#define SHUFFLEVECTOR 392
+#define GETRESULT 393
+#define EXTRACTVALUE 394
+#define INSERTVALUE 395
+#define SIGNEXT 396
+#define ZEROEXT 397
+#define NORETURN 398
+#define INREG 399
+#define SRET 400
+#define NOUNWIND 401
+#define NOALIAS 402
+#define BYVAL 403
+#define NEST 404
+#define READNONE 405
+#define READONLY 406
+#define GC 407
+#define DEFAULT 408
+#define HIDDEN 409
+#define PROTECTED 410
 
 
 
 
 /* Copy the first part of user declarations.  */
-#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 14 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
 
 #include "ParserInternals.h"
 #include "llvm/CallingConv.h"
@@ -845,7 +853,7 @@
   if (TriggerError) return 0;
 
   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
-    GenerateError("Invalid use of a composite type");
+    GenerateError("Invalid use of a non-first-class type");
     return 0;
   }
 
@@ -887,7 +895,7 @@
 
 /// defineBBVal - This is a definition of a new basic block with the specified
 /// identifier which must be the same as CurFun.NextValNum, if its numeric.
-static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) {
+static BasicBlock *defineBBVal(const ValID &ID) {
   assert(inFunctionScope() && "Can't get basic block at global scope!");
 
   BasicBlock *BB = 0;
@@ -929,7 +937,6 @@
   }
 
   ID.destroy();
-  BB->setUnwindDest(unwindDest);
   return BB;
 }
 
@@ -1102,6 +1109,10 @@
     GenerateError("Cannot declare global vars of function type");
     return 0;
   }
+  if (Ty == Type::LabelTy) {
+    GenerateError("Cannot declare global vars of label type");
+    return 0;
+  }
 
   const PointerType *PTy = PointerType::get(Ty, AddressSpace);
 
@@ -1337,7 +1348,7 @@
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 950 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 953 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
 {
   llvm::Module                           *ModuleVal;
   llvm::Function                         *FunctionVal;
@@ -1351,6 +1362,7 @@
   llvm::PATypeHolder                     *TypeVal;
   llvm::Value                            *ValueVal;
   std::vector<llvm::Value*>              *ValueList;
+  std::vector<unsigned>                  *ConstantList;
   llvm::ArgListType                      *ArgList;
   llvm::TypeWithAttrs                     TypeWithAttrs;
   llvm::TypeWithAttrsList                *TypeWithAttrsList;
@@ -1385,7 +1397,7 @@
   llvm::FCmpInst::Predicate         FPredicate;
 }
 /* Line 193 of yacc.c.  */
-#line 1389 "llvmAsmParser.tab.c"
+#line 1401 "llvmAsmParser.tab.c"
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
@@ -1398,7 +1410,7 @@
 
 
 /* Line 216 of yacc.c.  */
-#line 1402 "llvmAsmParser.tab.c"
+#line 1414 "llvmAsmParser.tab.c"
 
 #ifdef short
 # undef short
@@ -1611,22 +1623,22 @@
 #endif
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  43
+#define YYFINAL  44
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   2015
+#define YYLAST   2339
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  166
+#define YYNTOKENS  170
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  85
+#define YYNNTS  86
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  324
+#define YYNRULES  340
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  635
+#define YYNSTATES  699
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   406
+#define YYMAXUTOK   410
 
 #define YYTRANSLATE(YYX)						\
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -1638,15 +1650,15 @@
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     152,   153,   156,     2,   155,     2,     2,     2,     2,     2,
+     156,   157,   160,     2,   159,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     161,   154,   162,     2,     2,     2,     2,     2,     2,     2,
+     165,   158,   166,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,   158,   157,   160,     2,     2,     2,     2,     2,   165,
+       2,   162,   161,   164,     2,     2,     2,     2,     2,   169,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     159,     2,     2,   163,     2,   164,     2,     2,     2,     2,
+     163,     2,     2,   167,     2,   168,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -1674,7 +1686,8 @@
      115,   116,   117,   118,   119,   120,   121,   122,   123,   124,
      125,   126,   127,   128,   129,   130,   131,   132,   133,   134,
      135,   136,   137,   138,   139,   140,   141,   142,   143,   144,
-     145,   146,   147,   148,   149,   150,   151
+     145,   146,   147,   148,   149,   150,   151,   152,   153,   154,
+     155
 };
 
 #if YYDEBUG
@@ -1690,177 +1703,189 @@
       99,   101,   103,   105,   107,   109,   111,   113,   115,   117,
      119,   121,   123,   125,   127,   129,   130,   135,   136,   139,
      140,   142,   144,   146,   147,   150,   152,   154,   156,   158,
-     160,   162,   164,   166,   167,   169,   171,   173,   174,   176,
-     178,   179,   181,   183,   185,   187,   188,   190,   192,   193,
-     195,   197,   199,   201,   203,   206,   208,   210,   212,   214,
-     216,   218,   220,   222,   224,   227,   228,   231,   233,   235,
-     237,   239,   241,   243,   244,   247,   248,   251,   252,   255,
-     256,   260,   263,   264,   266,   267,   271,   273,   276,   278,
-     280,   282,   284,   286,   288,   290,   292,   294,   298,   300,
-     303,   309,   315,   321,   327,   331,   334,   340,   345,   348,
-     350,   352,   354,   358,   360,   364,   366,   367,   369,   373,
-     378,   382,   386,   391,   396,   400,   407,   413,   416,   419,
-     422,   425,   428,   431,   434,   437,   440,   443,   446,   449,
-     456,   462,   471,   478,   485,   493,   501,   508,   517,   526,
-     530,   532,   534,   536,   538,   539,   542,   549,   551,   552,
-     554,   557,   558,   562,   563,   567,   571,   575,   579,   580,
-     589,   590,   600,   601,   611,   617,   620,   624,   626,   630,
-     634,   638,   642,   644,   645,   651,   655,   657,   661,   663,
-     664,   675,   677,   679,   684,   686,   688,   691,   695,   696,
-     698,   700,   702,   704,   706,   708,   710,   712,   714,   718,
-     720,   726,   728,   730,   732,   734,   736,   738,   741,   743,
-     747,   750,   753,   757,   760,   761,   765,   767,   772,   775,
-     778,   782,   792,   802,   811,   826,   828,   830,   837,   843,
-     846,   853,   861,   866,   871,   878,   885,   886,   887,   891,
-     894,   896,   902,   908,   915,   922,   927,   934,   939,   944,
-     951,   958,   961,   970,   972,   974,   975,   979,   986,   990,
-     997,  1000,  1006,  1014,  1020
+     160,   162,   164,   166,   168,   169,   171,   173,   175,   176,
+     178,   180,   181,   183,   185,   187,   189,   190,   192,   194,
+     195,   197,   199,   201,   203,   205,   208,   210,   212,   214,
+     216,   218,   220,   222,   224,   226,   229,   230,   233,   235,
+     237,   239,   241,   243,   245,   246,   249,   250,   253,   254,
+     257,   258,   262,   265,   266,   268,   269,   273,   275,   278,
+     280,   282,   284,   286,   288,   290,   292,   294,   296,   300,
+     302,   305,   311,   317,   323,   329,   333,   336,   342,   347,
+     350,   352,   354,   356,   360,   362,   366,   368,   369,   371,
+     375,   380,   384,   388,   393,   398,   402,   409,   415,   418,
+     421,   424,   427,   430,   433,   436,   439,   442,   445,   448,
+     451,   458,   464,   473,   480,   487,   495,   503,   511,   519,
+     526,   535,   544,   550,   558,   562,   564,   566,   568,   570,
+     571,   574,   581,   583,   584,   586,   589,   590,   594,   595,
+     599,   603,   607,   611,   612,   621,   622,   632,   633,   643,
+     649,   652,   656,   658,   662,   666,   670,   674,   676,   677,
+     683,   687,   689,   693,   695,   696,   707,   709,   711,   716,
+     718,   720,   723,   727,   728,   730,   732,   734,   736,   738,
+     740,   742,   744,   746,   750,   754,   757,   760,   764,   767,
+     773,   778,   780,   786,   788,   790,   792,   794,   796,   798,
+     801,   803,   807,   810,   813,   817,   820,   821,   823,   826,
+     829,   833,   843,   853,   862,   877,   879,   881,   888,   894,
+     897,   904,   912,   917,   922,   929,   936,   937,   938,   942,
+     945,   949,   952,   954,   960,   966,   973,   980,   987,   994,
+     999,  1006,  1011,  1016,  1023,  1030,  1033,  1042,  1044,  1046,
+    1047,  1051,  1058,  1062,  1069,  1072,  1078,  1086,  1092,  1097,
+    1102
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 static const yytype_int16 yyrhs[] =
 {
-     212,     0,    -1,    75,    -1,    76,    -1,    77,    -1,    78,
+     216,     0,    -1,    75,    -1,    76,    -1,    77,    -1,    78,
       -1,    79,    -1,    80,    -1,    81,    -1,    82,    -1,    83,
       -1,    87,    -1,    88,    -1,    89,    -1,    84,    -1,    85,
-      -1,    86,    -1,   118,    -1,   119,    -1,   120,    -1,   121,
-      -1,   122,    -1,   123,    -1,   124,    -1,   125,    -1,   126,
-      -1,   127,    -1,   128,    -1,   129,    -1,    92,    -1,    93,
-      -1,    94,    -1,    95,    -1,    96,    -1,    97,    -1,    98,
-      -1,    99,    -1,   100,    -1,   101,    -1,   102,    -1,   103,
-      -1,   104,    -1,   105,    -1,   106,    -1,   107,    -1,   108,
-      -1,   109,    -1,   110,    -1,   111,    -1,    98,    -1,    99,
-      -1,   100,    -1,   101,    -1,    26,    -1,    27,    -1,    11,
+      -1,    86,    -1,   120,    -1,   121,    -1,   122,    -1,   123,
+      -1,   124,    -1,   125,    -1,   126,    -1,   127,    -1,   128,
+      -1,   129,    -1,   130,    -1,   131,    -1,    94,    -1,    95,
+      -1,    96,    -1,    97,    -1,    98,    -1,    99,    -1,   100,
+      -1,   101,    -1,   102,    -1,   103,    -1,   104,    -1,   105,
+      -1,   106,    -1,   107,    -1,   108,    -1,   109,    -1,   110,
+      -1,   111,    -1,   112,    -1,   113,    -1,   100,    -1,   101,
+      -1,   102,    -1,   103,    -1,    26,    -1,    27,    -1,    11,
       -1,    12,    -1,    13,    -1,    16,    -1,    15,    -1,    14,
-      -1,    19,    -1,    22,    -1,    24,    -1,   174,    -1,    -1,
-      54,   152,     4,   153,    -1,    -1,   174,   154,    -1,    -1,
-      20,    -1,    23,    -1,   180,    -1,    -1,   178,   154,    -1,
+      -1,    19,    -1,    22,    -1,    24,    -1,   178,    -1,    -1,
+      55,   156,     4,   157,    -1,    -1,   178,   158,    -1,    -1,
+      20,    -1,    23,    -1,   184,    -1,    -1,   182,   158,    -1,
       42,    -1,    44,    -1,    43,    -1,    45,    -1,    47,    -1,
-      46,    -1,    48,    -1,    50,    -1,    -1,   149,    -1,   150,
-      -1,   151,    -1,    -1,    46,    -1,    48,    -1,    -1,    42,
-      -1,    43,    -1,    44,    -1,    47,    -1,    -1,    44,    -1,
-      42,    -1,    -1,    62,    -1,    63,    -1,    64,    -1,    65,
-      -1,    66,    -1,    61,     4,    -1,   138,    -1,   119,    -1,
-     137,    -1,   120,    -1,   140,    -1,   141,    -1,   143,    -1,
-     144,    -1,   145,    -1,    53,     4,    -1,    -1,   189,   188,
-      -1,   139,    -1,   142,    -1,   138,    -1,   137,    -1,   146,
-      -1,   147,    -1,    -1,   191,   190,    -1,    -1,   148,    22,
-      -1,    -1,    53,     4,    -1,    -1,   155,    53,     4,    -1,
-      34,    22,    -1,    -1,   195,    -1,    -1,   155,   198,   197,
-      -1,   195,    -1,    53,     4,    -1,    11,    -1,    12,    -1,
-      13,    -1,    16,    -1,    15,    -1,    14,    -1,    17,    -1,
-      49,    -1,   199,    -1,   200,   176,   156,    -1,   234,    -1,
-     157,     4,    -1,   200,   152,   204,   153,   191,    -1,    10,
-     152,   204,   153,   191,    -1,   158,     4,   159,   200,   160,
-      -1,   161,     4,   159,   200,   162,    -1,   163,   205,   164,
-      -1,   163,   164,    -1,   161,   163,   205,   164,   162,    -1,
-     161,   163,   164,   162,    -1,   200,   189,    -1,   200,    -1,
-      10,    -1,   201,    -1,   203,   155,   201,    -1,   203,    -1,
-     203,   155,    39,    -1,    39,    -1,    -1,   200,    -1,   205,
-     155,   200,    -1,   200,   158,   208,   160,    -1,   200,   158,
-     160,    -1,   200,   165,    22,    -1,   200,   161,   208,   162,
-      -1,   200,   163,   208,   164,    -1,   200,   163,   164,    -1,
-     200,   161,   163,   208,   164,   162,    -1,   200,   161,   163,
-     164,   162,    -1,   200,    40,    -1,   200,    41,    -1,   200,
-     234,    -1,   200,   207,    -1,   200,    25,    -1,   172,     3,
-      -1,   172,     5,    -1,   172,     4,    -1,   172,     6,    -1,
-      11,    26,    -1,    11,    27,    -1,   173,     9,    -1,   169,
-     152,   206,    38,   200,   153,    -1,   117,   152,   206,   246,
-     153,    -1,   131,   152,   206,   155,   206,   155,   206,   153,
-      -1,   167,   152,   206,   155,   206,   153,    -1,   168,   152,
-     206,   155,   206,   153,    -1,    90,   170,   152,   206,   155,
-     206,   153,    -1,    91,   171,   152,   206,   155,   206,   153,
-      -1,   133,   152,   206,   155,   206,   153,    -1,   134,   152,
-     206,   155,   206,   155,   206,   153,    -1,   135,   152,   206,
-     155,   206,   155,   206,   153,    -1,   208,   155,   206,    -1,
-     206,    -1,    32,    -1,    33,    -1,    37,    -1,    -1,   202,
-     234,    -1,   123,   152,   211,    38,   200,   153,    -1,   213,
-      -1,    -1,   214,    -1,   213,   214,    -1,    -1,    31,   215,
-     230,    -1,    -1,    30,   216,   231,    -1,    59,    58,   220,
-      -1,   177,    18,   200,    -1,   177,    18,    10,    -1,    -1,
-     179,   183,   210,   209,   206,   176,   217,   197,    -1,    -1,
-     179,   181,   183,   210,   209,   206,   176,   218,   197,    -1,
-      -1,   179,   182,   183,   210,   209,   200,   176,   219,   197,
-      -1,   179,   183,    35,   186,   211,    -1,    51,   221,    -1,
-      55,   154,   222,    -1,    22,    -1,    52,   154,    22,    -1,
-      67,   154,    22,    -1,   158,   223,   160,    -1,   223,   155,
-      22,    -1,    22,    -1,    -1,   224,   155,   200,   189,   175,
-      -1,   200,   189,   175,    -1,   224,    -1,   224,   155,    39,
-      -1,    39,    -1,    -1,   187,   202,   178,   152,   225,   153,
-     191,   196,   193,   192,    -1,    28,    -1,   163,    -1,   185,
-     183,   226,   227,    -1,    29,    -1,   164,    -1,   238,   229,
-      -1,   184,   183,   226,    -1,    -1,    60,    -1,     3,    -1,
-       4,    -1,     9,    -1,    26,    -1,    27,    -1,    40,    -1,
-      41,    -1,    25,    -1,   161,   208,   162,    -1,   207,    -1,
-      58,   232,    22,   155,    22,    -1,     7,    -1,     8,    -1,
-     174,    -1,   178,    -1,   234,    -1,   233,    -1,   200,   235,
-      -1,   236,    -1,   237,   155,   236,    -1,   238,   239,    -1,
-     228,   239,    -1,   240,   177,   241,    -1,   240,   243,    -1,
-      -1,    68,    38,   235,    -1,    21,    -1,    21,    68,    38,
-     235,    -1,    69,   237,    -1,    69,    10,    -1,    70,    17,
-     235,    -1,    70,    11,   235,   155,    17,   235,   155,    17,
-     235,    -1,    71,   172,   235,   155,    17,   235,   158,   242,
-     160,    -1,    71,   172,   235,   155,    17,   235,   158,   160,
-      -1,    72,   187,   202,   235,   152,   245,   153,   191,    38,
-      17,   235,    73,    17,   235,    -1,    73,    -1,    74,    -1,
-     242,   172,   233,   155,    17,   235,    -1,   172,   233,   155,
-      17,   235,    -1,   177,   248,    -1,   200,   158,   235,   155,
-     235,   160,    -1,   244,   155,   158,   235,   155,   235,   160,
-      -1,   200,   189,   235,   189,    -1,    17,   189,   235,   189,
-      -1,   245,   155,   200,   189,   235,   189,    -1,   245,   155,
-      17,   189,   235,   189,    -1,    -1,    -1,   246,   155,   236,
-      -1,    57,    56,    -1,    56,    -1,   167,   200,   235,   155,
-     235,    -1,   168,   200,   235,   155,   235,    -1,    90,   170,
-     200,   235,   155,   235,    -1,    91,   171,   200,   235,   155,
-     235,    -1,   169,   236,    38,   200,    -1,   131,   236,   155,
-     236,   155,   236,    -1,   132,   236,   155,   200,    -1,   133,
-     236,   155,   236,    -1,   134,   236,   155,   236,   155,   236,
-      -1,   135,   236,   155,   236,   155,   236,    -1,   130,   244,
-      -1,   247,   187,   202,   235,   152,   245,   153,   191,    -1,
-     250,    -1,    36,    -1,    -1,   112,   200,   194,    -1,   112,
-     200,   155,    11,   235,   194,    -1,   113,   200,   194,    -1,
-     113,   200,   155,    11,   235,   194,    -1,   114,   236,    -1,
-     249,   115,   200,   235,   194,    -1,   249,   116,   236,   155,
-     200,   235,   194,    -1,   136,   200,   234,   155,     4,    -1,
-     117,   200,   235,   246,    -1
+      49,    -1,    46,    -1,    48,    -1,    51,    -1,    -1,   153,
+      -1,   154,    -1,   155,    -1,    -1,    46,    -1,    48,    -1,
+      -1,    42,    -1,    43,    -1,    44,    -1,    47,    -1,    -1,
+      44,    -1,    42,    -1,    -1,    63,    -1,    64,    -1,    65,
+      -1,    66,    -1,    67,    -1,    62,     4,    -1,   142,    -1,
+     121,    -1,   141,    -1,   122,    -1,   144,    -1,   145,    -1,
+     147,    -1,   148,    -1,   149,    -1,    54,     4,    -1,    -1,
+     193,   192,    -1,   143,    -1,   146,    -1,   142,    -1,   141,
+      -1,   150,    -1,   151,    -1,    -1,   195,   194,    -1,    -1,
+     152,    22,    -1,    -1,    54,     4,    -1,    -1,   159,    54,
+       4,    -1,    34,    22,    -1,    -1,   199,    -1,    -1,   159,
+     202,   201,    -1,   199,    -1,    54,     4,    -1,    11,    -1,
+      12,    -1,    13,    -1,    16,    -1,    15,    -1,    14,    -1,
+      17,    -1,    50,    -1,   203,    -1,   204,   180,   160,    -1,
+     238,    -1,   161,     4,    -1,   204,   156,   208,   157,   195,
+      -1,    10,   156,   208,   157,   195,    -1,   162,     4,   163,
+     204,   164,    -1,   165,     4,   163,   204,   166,    -1,   167,
+     209,   168,    -1,   167,   168,    -1,   165,   167,   209,   168,
+     166,    -1,   165,   167,   168,   166,    -1,   204,   193,    -1,
+     204,    -1,    10,    -1,   205,    -1,   207,   159,   205,    -1,
+     207,    -1,   207,   159,    39,    -1,    39,    -1,    -1,   204,
+      -1,   209,   159,   204,    -1,   204,   162,   212,   164,    -1,
+     204,   162,   164,    -1,   204,   169,    22,    -1,   204,   165,
+     212,   166,    -1,   204,   167,   212,   168,    -1,   204,   167,
+     168,    -1,   204,   165,   167,   212,   168,   166,    -1,   204,
+     165,   167,   168,   166,    -1,   204,    40,    -1,   204,    41,
+      -1,   204,   238,    -1,   204,   211,    -1,   204,    25,    -1,
+     176,     3,    -1,   176,     5,    -1,   176,     4,    -1,   176,
+       6,    -1,    11,    26,    -1,    11,    27,    -1,   177,     9,
+      -1,   173,   156,   210,    38,   204,   157,    -1,   119,   156,
+     210,   250,   157,    -1,   133,   156,   210,   159,   210,   159,
+     210,   157,    -1,   171,   156,   210,   159,   210,   157,    -1,
+     172,   156,   210,   159,   210,   157,    -1,    90,   174,   156,
+     210,   159,   210,   157,    -1,    91,   175,   156,   210,   159,
+     210,   157,    -1,    92,   174,   156,   210,   159,   210,   157,
+      -1,    93,   175,   156,   210,   159,   210,   157,    -1,   135,
+     156,   210,   159,   210,   157,    -1,   136,   156,   210,   159,
+     210,   159,   210,   157,    -1,   137,   156,   210,   159,   210,
+     159,   210,   157,    -1,   139,   156,   210,   251,   157,    -1,
+     140,   156,   210,   159,   210,   251,   157,    -1,   212,   159,
+     210,    -1,   210,    -1,    32,    -1,    33,    -1,    37,    -1,
+      -1,   206,   238,    -1,   125,   156,   215,    38,   204,   157,
+      -1,   217,    -1,    -1,   218,    -1,   217,   218,    -1,    -1,
+      31,   219,   234,    -1,    -1,    30,   220,   235,    -1,    60,
+      59,   224,    -1,   181,    18,   204,    -1,   181,    18,    10,
+      -1,    -1,   183,   187,   214,   213,   210,   180,   221,   201,
+      -1,    -1,   183,   185,   187,   214,   213,   210,   180,   222,
+     201,    -1,    -1,   183,   186,   187,   214,   213,   204,   180,
+     223,   201,    -1,   183,   187,    35,   190,   215,    -1,    52,
+     225,    -1,    56,   158,   226,    -1,    22,    -1,    53,   158,
+      22,    -1,    68,   158,    22,    -1,   162,   227,   164,    -1,
+     227,   159,    22,    -1,    22,    -1,    -1,   228,   159,   204,
+     193,   179,    -1,   204,   193,   179,    -1,   228,    -1,   228,
+     159,    39,    -1,    39,    -1,    -1,   191,   206,   182,   156,
+     229,   157,   195,   200,   197,   196,    -1,    28,    -1,   167,
+      -1,   189,   187,   230,   231,    -1,    29,    -1,   168,    -1,
+     242,   233,    -1,   188,   187,   230,    -1,    -1,    61,    -1,
+       3,    -1,     4,    -1,     9,    -1,    26,    -1,    27,    -1,
+      40,    -1,    41,    -1,    25,    -1,   165,   212,   166,    -1,
+     162,   212,   164,    -1,   162,   164,    -1,   169,    22,    -1,
+     167,   212,   168,    -1,   167,   168,    -1,   165,   167,   212,
+     168,   166,    -1,   165,   167,   168,   166,    -1,   211,    -1,
+      59,   236,    22,   159,    22,    -1,     7,    -1,     8,    -1,
+     178,    -1,   182,    -1,   238,    -1,   237,    -1,   204,   239,
+      -1,   240,    -1,   241,   159,   240,    -1,   242,   243,    -1,
+     232,   243,    -1,   244,   181,   245,    -1,   244,   247,    -1,
+      -1,    21,    -1,    69,   241,    -1,    69,    10,    -1,    70,
+      17,   239,    -1,    70,    11,   239,   159,    17,   239,   159,
+      17,   239,    -1,    71,   176,   239,   159,    17,   239,   162,
+     246,   164,    -1,    71,   176,   239,   159,    17,   239,   162,
+     164,    -1,    72,   191,   206,   239,   156,   249,   157,   195,
+      38,    17,   239,    73,    17,   239,    -1,    73,    -1,    74,
+      -1,   246,   176,   237,   159,    17,   239,    -1,   176,   237,
+     159,    17,   239,    -1,   181,   253,    -1,   204,   162,   239,
+     159,   239,   164,    -1,   248,   159,   162,   239,   159,   239,
+     164,    -1,   204,   193,   239,   193,    -1,    17,   193,   239,
+     193,    -1,   249,   159,   204,   193,   239,   193,    -1,   249,
+     159,    17,   193,   239,   193,    -1,    -1,    -1,   250,   159,
+     240,    -1,   159,     4,    -1,   251,   159,     4,    -1,    58,
+      57,    -1,    57,    -1,   171,   204,   239,   159,   239,    -1,
+     172,   204,   239,   159,   239,    -1,    90,   174,   204,   239,
+     159,   239,    -1,    91,   175,   204,   239,   159,   239,    -1,
+      92,   174,   204,   239,   159,   239,    -1,    93,   175,   204,
+     239,   159,   239,    -1,   173,   240,    38,   204,    -1,   133,
+     240,   159,   240,   159,   240,    -1,   134,   240,   159,   204,
+      -1,   135,   240,   159,   240,    -1,   136,   240,   159,   240,
+     159,   240,    -1,   137,   240,   159,   240,   159,   240,    -1,
+     132,   248,    -1,   252,   191,   206,   239,   156,   249,   157,
+     195,    -1,   255,    -1,    36,    -1,    -1,   114,   204,   198,
+      -1,   114,   204,   159,    11,   239,   198,    -1,   115,   204,
+     198,    -1,   115,   204,   159,    11,   239,   198,    -1,   116,
+     240,    -1,   254,   117,   204,   239,   198,    -1,   254,   118,
+     240,   159,   204,   239,   198,    -1,   138,   204,   239,   159,
+       4,    -1,   119,   204,   239,   250,    -1,   139,   204,   239,
+     251,    -1,   140,   204,   239,   159,   204,   239,   251,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,  1112,  1112,  1112,  1112,  1112,  1112,  1112,  1112,  1112,
-    1112,  1113,  1113,  1113,  1113,  1113,  1113,  1114,  1114,  1114,
-    1114,  1114,  1114,  1115,  1115,  1115,  1115,  1115,  1115,  1118,
-    1118,  1119,  1119,  1120,  1120,  1121,  1121,  1122,  1122,  1126,
-    1126,  1127,  1127,  1128,  1128,  1129,  1129,  1130,  1130,  1131,
-    1131,  1132,  1132,  1133,  1134,  1139,  1140,  1140,  1140,  1140,
-    1140,  1142,  1142,  1142,  1143,  1143,  1145,  1146,  1150,  1154,
-    1159,  1159,  1161,  1162,  1167,  1173,  1174,  1175,  1176,  1177,
-    1181,  1182,  1183,  1187,  1188,  1189,  1190,  1194,  1195,  1196,
-    1200,  1201,  1202,  1203,  1204,  1208,  1209,  1210,  1213,  1214,
-    1215,  1216,  1217,  1218,  1219,  1226,  1227,  1228,  1229,  1230,
-    1231,  1232,  1233,  1234,  1235,  1239,  1240,  1245,  1246,  1247,
-    1248,  1249,  1250,  1253,  1254,  1259,  1260,  1267,  1268,  1274,
-    1275,  1284,  1292,  1293,  1298,  1299,  1300,  1305,  1318,  1318,
-    1318,  1318,  1318,  1318,  1318,  1321,  1325,  1329,  1336,  1341,
-    1349,  1380,  1405,  1410,  1420,  1430,  1434,  1444,  1451,  1460,
-    1467,  1472,  1477,  1484,  1485,  1492,  1499,  1507,  1513,  1525,
-    1553,  1569,  1596,  1624,  1650,  1670,  1696,  1716,  1728,  1735,
-    1801,  1811,  1821,  1827,  1837,  1843,  1853,  1858,  1863,  1876,
-    1888,  1910,  1918,  1924,  1935,  1940,  1945,  1951,  1957,  1966,
-    1970,  1978,  1978,  1981,  1981,  1984,  1996,  2017,  2022,  2030,
-    2031,  2035,  2035,  2039,  2039,  2042,  2045,  2069,  2081,  2080,
-    2092,  2091,  2101,  2100,  2111,  2151,  2154,  2160,  2170,  2174,
-    2179,  2181,  2186,  2191,  2200,  2210,  2221,  2225,  2234,  2243,
-    2248,  2374,  2374,  2376,  2385,  2385,  2387,  2392,  2404,  2408,
-    2413,  2417,  2421,  2425,  2429,  2433,  2437,  2441,  2445,  2470,
-    2474,  2484,  2488,  2492,  2497,  2504,  2504,  2510,  2519,  2524,
-    2529,  2533,  2542,  2551,  2560,  2564,  2568,  2573,  2580,  2587,
-    2591,  2596,  2606,  2625,  2634,  2715,  2719,  2726,  2737,  2750,
-    2760,  2771,  2781,  2792,  2800,  2810,  2817,  2820,  2821,  2828,
-    2832,  2837,  2853,  2870,  2884,  2898,  2910,  2918,  2925,  2931,
-    2937,  2943,  2958,  3044,  3049,  3053,  3060,  3067,  3075,  3082,
-    3090,  3098,  3112,  3129,  3137
+       0,  1118,  1118,  1118,  1118,  1118,  1118,  1118,  1118,  1118,
+    1118,  1119,  1119,  1119,  1119,  1119,  1119,  1120,  1120,  1120,
+    1120,  1120,  1120,  1121,  1121,  1121,  1121,  1121,  1121,  1124,
+    1124,  1125,  1125,  1126,  1126,  1127,  1127,  1128,  1128,  1132,
+    1132,  1133,  1133,  1134,  1134,  1135,  1135,  1136,  1136,  1137,
+    1137,  1138,  1138,  1139,  1140,  1145,  1146,  1146,  1146,  1146,
+    1146,  1148,  1148,  1148,  1149,  1149,  1151,  1152,  1156,  1160,
+    1165,  1165,  1167,  1168,  1173,  1179,  1180,  1181,  1182,  1183,
+    1184,  1188,  1189,  1190,  1194,  1195,  1196,  1197,  1201,  1202,
+    1203,  1207,  1208,  1209,  1210,  1211,  1215,  1216,  1217,  1220,
+    1221,  1222,  1223,  1224,  1225,  1226,  1233,  1234,  1235,  1236,
+    1237,  1238,  1239,  1240,  1241,  1242,  1246,  1247,  1252,  1253,
+    1254,  1255,  1256,  1257,  1260,  1261,  1266,  1267,  1274,  1275,
+    1281,  1282,  1291,  1299,  1300,  1305,  1306,  1307,  1312,  1325,
+    1325,  1325,  1325,  1325,  1325,  1325,  1328,  1332,  1336,  1343,
+    1348,  1356,  1385,  1410,  1415,  1425,  1435,  1439,  1449,  1456,
+    1465,  1472,  1477,  1482,  1489,  1490,  1497,  1504,  1512,  1518,
+    1530,  1558,  1574,  1601,  1629,  1655,  1675,  1701,  1721,  1733,
+    1740,  1806,  1816,  1826,  1832,  1842,  1848,  1858,  1864,  1870,
+    1883,  1895,  1916,  1924,  1930,  1941,  1946,  1951,  1956,  1961,
+    1967,  1973,  1979,  1987,  1998,  2002,  2010,  2010,  2013,  2013,
+    2016,  2028,  2049,  2054,  2062,  2063,  2067,  2067,  2071,  2071,
+    2074,  2077,  2101,  2113,  2112,  2124,  2123,  2133,  2132,  2143,
+    2183,  2186,  2192,  2202,  2206,  2211,  2213,  2218,  2223,  2232,
+    2242,  2253,  2257,  2266,  2275,  2280,  2409,  2409,  2411,  2420,
+    2420,  2422,  2427,  2439,  2443,  2448,  2452,  2456,  2460,  2464,
+    2468,  2472,  2476,  2480,  2502,  2524,  2530,  2543,  2555,  2560,
+    2572,  2578,  2582,  2592,  2596,  2600,  2605,  2612,  2612,  2618,
+    2627,  2632,  2637,  2641,  2650,  2659,  2668,  2672,  2680,  2687,
+    2691,  2696,  2707,  2726,  2735,  2821,  2825,  2832,  2843,  2856,
+    2866,  2877,  2887,  2898,  2906,  2916,  2923,  2926,  2927,  2935,
+    2941,  2950,  2954,  2959,  2975,  2992,  3006,  3020,  3034,  3048,
+    3060,  3068,  3075,  3081,  3087,  3093,  3108,  3198,  3203,  3207,
+    3214,  3221,  3231,  3238,  3248,  3256,  3270,  3287,  3295,  3310,
+    3325
 };
 #endif
 
@@ -1877,31 +1902,31 @@
   "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
   "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
   "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
-  "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
+  "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "COMMON", "OPAQUE",
   "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
   "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
   "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
-  "DATALAYOUT", "UNWINDS", "RET", "BR", "SWITCH", "INVOKE", "UNWIND",
-  "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM",
-  "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP",
-  "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
+  "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
+  "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
+  "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "VICMP",
+  "VFCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
   "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
   "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
   "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
   "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
   "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
-  "GETRESULT", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET",
-  "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "READNONE", "READONLY", "GC",
-  "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
-  "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
-  "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
-  "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName",
-  "OptAddrSpace", "OptLocalAssign", "GlobalName", "OptGlobalAssign",
-  "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
-  "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
-  "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
-  "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", "OptCAlign",
-  "SectionString", "OptSection", "GlobalVarAttributes",
+  "GETRESULT", "EXTRACTVALUE", "INSERTVALUE", "SIGNEXT", "ZEROEXT",
+  "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
+  "READNONE", "READONLY", "GC", "DEFAULT", "HIDDEN", "PROTECTED", "'('",
+  "')'", "'='", "','", "'*'", "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'",
+  "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", "LogicalOps", "CastOps",
+  "IPredicates", "FPredicates", "IntType", "FPType", "LocalName",
+  "OptLocalName", "OptAddrSpace", "OptLocalAssign", "GlobalName",
+  "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
+  "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
+  "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
+  "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign",
+  "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
   "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
   "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
   "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
@@ -1911,8 +1936,9 @@
   "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
   "SymbolicValueRef", "ValueRef", "ResolvedVal", "ReturnedVal",
   "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
-  "JumpTable", "Inst", "PHIList", "ParamList", "IndexList", "OptTailCall",
-  "InstVal", "OptVolatile", "MemoryInst", 0
+  "JumpTable", "Inst", "PHIList", "ParamList", "IndexList",
+  "ConstantIndexList", "OptTailCall", "InstVal", "OptVolatile",
+  "MemoryInst", 0
 };
 #endif
 
@@ -1936,47 +1962,49 @@
      375,   376,   377,   378,   379,   380,   381,   382,   383,   384,
      385,   386,   387,   388,   389,   390,   391,   392,   393,   394,
      395,   396,   397,   398,   399,   400,   401,   402,   403,   404,
-     405,   406,    40,    41,    61,    44,    42,    92,    91,   120,
-      93,    60,    62,   123,   125,    99
+     405,   406,   407,   408,   409,   410,    40,    41,    61,    44,
+      42,    92,    91,   120,    93,    60,    62,   123,   125,    99
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,   166,   167,   167,   167,   167,   167,   167,   167,   167,
-     167,   168,   168,   168,   168,   168,   168,   169,   169,   169,
-     169,   169,   169,   169,   169,   169,   169,   169,   169,   170,
-     170,   170,   170,   170,   170,   170,   170,   170,   170,   171,
-     171,   171,   171,   171,   171,   171,   171,   171,   171,   171,
-     171,   171,   171,   171,   171,   172,   173,   173,   173,   173,
-     173,   174,   174,   174,   175,   175,   176,   176,   177,   177,
-     178,   178,   179,   179,   180,   181,   181,   181,   181,   181,
-     182,   182,   182,   183,   183,   183,   183,   184,   184,   184,
-     185,   185,   185,   185,   185,   186,   186,   186,   187,   187,
-     187,   187,   187,   187,   187,   188,   188,   188,   188,   188,
-     188,   188,   188,   188,   188,   189,   189,   190,   190,   190,
-     190,   190,   190,   191,   191,   192,   192,   193,   193,   194,
-     194,   195,   196,   196,   197,   197,   198,   198,   199,   199,
-     199,   199,   199,   199,   199,   200,   200,   200,   200,   200,
-     200,   200,   200,   200,   200,   200,   200,   200,   201,   202,
-     202,   203,   203,   204,   204,   204,   204,   205,   205,   206,
-     206,   206,   206,   206,   206,   206,   206,   206,   206,   206,
-     206,   206,   206,   206,   206,   206,   206,   206,   206,   207,
-     207,   207,   207,   207,   207,   207,   207,   207,   207,   208,
-     208,   209,   209,   210,   210,   211,   211,   212,   212,   213,
-     213,   215,   214,   216,   214,   214,   214,   214,   217,   214,
-     218,   214,   219,   214,   214,   214,   214,   220,   221,   221,
-     222,   223,   223,   223,   224,   224,   225,   225,   225,   225,
-     226,   227,   227,   228,   229,   229,   230,   231,   232,   232,
-     233,   233,   233,   233,   233,   233,   233,   233,   233,   233,
-     233,   234,   234,   234,   234,   235,   235,   236,   237,   237,
-     238,   238,   239,   240,   240,   240,   240,   240,   241,   241,
-     241,   241,   241,   241,   241,   241,   241,   242,   242,   243,
-     244,   244,   245,   245,   245,   245,   245,   246,   246,   247,
-     247,   248,   248,   248,   248,   248,   248,   248,   248,   248,
-     248,   248,   248,   248,   249,   249,   250,   250,   250,   250,
-     250,   250,   250,   250,   250
+       0,   170,   171,   171,   171,   171,   171,   171,   171,   171,
+     171,   172,   172,   172,   172,   172,   172,   173,   173,   173,
+     173,   173,   173,   173,   173,   173,   173,   173,   173,   174,
+     174,   174,   174,   174,   174,   174,   174,   174,   174,   175,
+     175,   175,   175,   175,   175,   175,   175,   175,   175,   175,
+     175,   175,   175,   175,   175,   176,   177,   177,   177,   177,
+     177,   178,   178,   178,   179,   179,   180,   180,   181,   181,
+     182,   182,   183,   183,   184,   185,   185,   185,   185,   185,
+     185,   186,   186,   186,   187,   187,   187,   187,   188,   188,
+     188,   189,   189,   189,   189,   189,   190,   190,   190,   191,
+     191,   191,   191,   191,   191,   191,   192,   192,   192,   192,
+     192,   192,   192,   192,   192,   192,   193,   193,   194,   194,
+     194,   194,   194,   194,   195,   195,   196,   196,   197,   197,
+     198,   198,   199,   200,   200,   201,   201,   202,   202,   203,
+     203,   203,   203,   203,   203,   203,   204,   204,   204,   204,
+     204,   204,   204,   204,   204,   204,   204,   204,   204,   205,
+     206,   206,   207,   207,   208,   208,   208,   208,   209,   209,
+     210,   210,   210,   210,   210,   210,   210,   210,   210,   210,
+     210,   210,   210,   210,   210,   210,   210,   210,   210,   210,
+     211,   211,   211,   211,   211,   211,   211,   211,   211,   211,
+     211,   211,   211,   211,   212,   212,   213,   213,   214,   214,
+     215,   215,   216,   216,   217,   217,   219,   218,   220,   218,
+     218,   218,   218,   221,   218,   222,   218,   223,   218,   218,
+     218,   218,   224,   225,   225,   226,   227,   227,   227,   228,
+     228,   229,   229,   229,   229,   230,   231,   231,   232,   233,
+     233,   234,   235,   236,   236,   237,   237,   237,   237,   237,
+     237,   237,   237,   237,   237,   237,   237,   237,   237,   237,
+     237,   237,   237,   238,   238,   238,   238,   239,   239,   240,
+     241,   241,   242,   242,   243,   244,   244,   244,   245,   245,
+     245,   245,   245,   245,   245,   245,   245,   246,   246,   247,
+     248,   248,   249,   249,   249,   249,   249,   250,   250,   251,
+     251,   252,   252,   253,   253,   253,   253,   253,   253,   253,
+     253,   253,   253,   253,   253,   253,   253,   253,   254,   254,
+     255,   255,   255,   255,   255,   255,   255,   255,   255,   255,
+     255
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
@@ -1990,31 +2018,33 @@
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
        1,     1,     1,     1,     1,     0,     4,     0,     2,     0,
        1,     1,     1,     0,     2,     1,     1,     1,     1,     1,
-       1,     1,     1,     0,     1,     1,     1,     0,     1,     1,
-       0,     1,     1,     1,     1,     0,     1,     1,     0,     1,
-       1,     1,     1,     1,     2,     1,     1,     1,     1,     1,
-       1,     1,     1,     1,     2,     0,     2,     1,     1,     1,
-       1,     1,     1,     0,     2,     0,     2,     0,     2,     0,
-       3,     2,     0,     1,     0,     3,     1,     2,     1,     1,
-       1,     1,     1,     1,     1,     1,     1,     3,     1,     2,
-       5,     5,     5,     5,     3,     2,     5,     4,     2,     1,
-       1,     1,     3,     1,     3,     1,     0,     1,     3,     4,
-       3,     3,     4,     4,     3,     6,     5,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     6,
-       5,     8,     6,     6,     7,     7,     6,     8,     8,     3,
-       1,     1,     1,     1,     0,     2,     6,     1,     0,     1,
-       2,     0,     3,     0,     3,     3,     3,     3,     0,     8,
-       0,     9,     0,     9,     5,     2,     3,     1,     3,     3,
-       3,     3,     1,     0,     5,     3,     1,     3,     1,     0,
-      10,     1,     1,     4,     1,     1,     2,     3,     0,     1,
+       1,     1,     1,     1,     0,     1,     1,     1,     0,     1,
+       1,     0,     1,     1,     1,     1,     0,     1,     1,     0,
+       1,     1,     1,     1,     1,     2,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     2,     0,     2,     1,     1,
+       1,     1,     1,     1,     0,     2,     0,     2,     0,     2,
+       0,     3,     2,     0,     1,     0,     3,     1,     2,     1,
        1,     1,     1,     1,     1,     1,     1,     1,     3,     1,
-       5,     1,     1,     1,     1,     1,     1,     2,     1,     3,
-       2,     2,     3,     2,     0,     3,     1,     4,     2,     2,
+       2,     5,     5,     5,     5,     3,     2,     5,     4,     2,
+       1,     1,     1,     3,     1,     3,     1,     0,     1,     3,
+       4,     3,     3,     4,     4,     3,     6,     5,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       6,     5,     8,     6,     6,     7,     7,     7,     7,     6,
+       8,     8,     5,     7,     3,     1,     1,     1,     1,     0,
+       2,     6,     1,     0,     1,     2,     0,     3,     0,     3,
+       3,     3,     3,     0,     8,     0,     9,     0,     9,     5,
+       2,     3,     1,     3,     3,     3,     3,     1,     0,     5,
+       3,     1,     3,     1,     0,    10,     1,     1,     4,     1,
+       1,     2,     3,     0,     1,     1,     1,     1,     1,     1,
+       1,     1,     1,     3,     3,     2,     2,     3,     2,     5,
+       4,     1,     5,     1,     1,     1,     1,     1,     1,     2,
+       1,     3,     2,     2,     3,     2,     0,     1,     2,     2,
        3,     9,     9,     8,    14,     1,     1,     6,     5,     2,
        6,     7,     4,     4,     6,     6,     0,     0,     3,     2,
-       1,     5,     5,     6,     6,     4,     6,     4,     4,     6,
-       6,     2,     8,     1,     1,     0,     3,     6,     3,     6,
-       2,     5,     7,     5,     4
+       3,     2,     1,     5,     5,     6,     6,     6,     6,     4,
+       6,     4,     4,     6,     6,     2,     8,     1,     1,     0,
+       3,     6,     3,     6,     2,     5,     7,     5,     4,     4,
+       7
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -2022,656 +2052,738 @@
    means the default is an error.  */
 static const yytype_uint16 yydefact[] =
 {
-      73,    61,    70,    62,    71,    63,   213,   211,     0,     0,
-       0,     0,     0,     0,    83,    72,     0,    73,   209,    87,
-      90,     0,     0,   225,     0,     0,    68,     0,    74,    75,
-      77,    76,    78,    80,    79,    81,    82,    84,    85,    86,
-      83,    83,   204,     1,   210,    88,    89,    83,   214,    91,
-      92,    93,    94,    83,   274,   212,   274,     0,     0,   233,
-     226,   227,   215,   261,   262,   217,   138,   139,   140,   143,
-     142,   141,   144,   145,     0,     0,     0,     0,   263,   264,
-     146,   216,   148,   204,   204,    95,   203,     0,    98,    98,
-     276,     0,   271,    69,   244,   245,   246,   270,   228,   229,
-     232,     0,   166,   149,     0,     0,     0,     0,   155,   167,
-       0,     0,   166,     0,     0,     0,    97,    96,     0,   201,
-     202,     0,     0,    99,   100,   101,   102,   103,     0,   247,
-       0,     0,     0,   315,   273,     0,   230,   165,   115,   161,
-     163,     0,     0,     0,     0,     0,     0,   154,     0,     0,
-     147,     0,     0,   160,     0,   159,     0,   224,   138,   139,
-     140,   143,   142,   141,     0,     0,    67,    67,   104,     0,
-     241,   242,   243,     0,   250,   251,   252,   257,   253,   254,
-     255,   256,   248,     2,     3,     4,     5,     6,     7,     8,
-       9,    10,    14,    15,    16,    11,    12,    13,     0,     0,
-       0,    17,    18,    19,    20,    21,    22,    23,    24,    25,
-      26,    27,    28,     0,     0,     0,     0,     0,     0,     0,
-       0,   259,   266,   265,   275,   314,   300,     0,     0,     0,
-       0,    98,   285,   286,     0,     0,     0,     0,     0,     0,
+      73,    61,    70,    62,    71,    63,   218,   216,     0,     0,
+       0,     0,     0,     0,    84,    72,     0,    73,   214,    88,
+      91,     0,     0,   230,     0,     0,    68,     0,    74,    75,
+      77,    76,    78,    81,    79,    82,    80,    83,    85,    86,
+      87,    84,    84,   209,     1,   215,    89,    90,    84,   219,
+      92,    93,    94,    95,    84,   286,   217,   286,     0,     0,
+     238,   231,   232,   220,   273,   274,   222,   139,   140,   141,
+     144,   143,   142,   145,   146,     0,     0,     0,     0,   275,
+     276,   147,   221,   149,   209,   209,    96,   208,     0,    99,
+      99,   287,   283,    69,   249,   250,   251,   282,   233,   234,
+     237,     0,   167,   150,     0,     0,     0,     0,   156,   168,
+       0,     0,   167,     0,     0,     0,    98,    97,     0,   206,
+     207,     0,     0,   100,   101,   102,   103,   104,     0,   252,
+       0,   329,   285,     0,   235,   166,   116,   162,   164,     0,
+       0,     0,     0,     0,     0,   155,     0,     0,   148,     0,
+       0,   161,     0,   160,     0,   229,   139,   140,   141,   144,
+     143,   142,     0,     0,    67,    67,   105,     0,   246,   247,
+     248,   328,   312,     0,     0,     0,     0,    99,   295,   296,
+       2,     3,     4,     5,     6,     7,     8,     9,    10,    14,
+      15,    16,    11,    12,    13,     0,     0,     0,     0,     0,
+       0,     0,     0,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,    27,    28,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   284,    99,   299,
+       0,   327,   236,   159,     0,   124,    67,    67,   158,     0,
+     169,     0,   124,    67,    67,     0,   210,   187,   188,   183,
+     185,   184,   186,   189,   182,   178,   179,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-     272,    98,   289,     0,   313,   231,   158,     0,   123,    67,
-      67,   157,     0,   168,     0,   123,    67,    67,     0,   205,
-     186,   187,   182,   184,   183,   185,   188,   181,   177,   178,
-       0,     0,     0,     0,   180,   179,   218,     0,   277,   249,
-       0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
-      38,     0,    53,    54,    49,    50,    51,    52,    39,    40,
-      41,    42,    43,    44,    45,    46,    47,    48,     0,     0,
-       0,     0,     0,     0,   200,     0,     0,     0,     0,   299,
-     279,    67,   268,   278,     0,     0,    55,     0,     0,     0,
-       0,   129,   129,   320,    67,    67,   311,     0,     0,     0,
-       0,     0,    67,    67,    67,     0,     0,     0,     0,     0,
-     106,   108,   107,   105,   109,   110,   111,   112,   113,   116,
-     164,   162,   151,   152,   153,   156,    66,   150,   220,   222,
-       0,   170,     0,     0,     0,   174,     0,   171,   134,   239,
-       0,     0,     0,   297,     0,     0,     0,     0,     0,   258,
-       0,     0,     0,   267,     0,     0,   280,     0,     0,    67,
-      67,     0,   316,     0,   318,   297,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    67,     0,
-     114,   120,   119,   117,   118,   121,   122,   124,   134,   134,
-       0,   169,   155,   167,     0,   172,   173,     0,   219,   238,
-     115,   236,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,   199,     0,     0,     0,   269,     0,     0,     0,     0,
-       0,     0,     0,     0,   324,     0,     0,     0,   307,   308,
-       0,     0,     0,     0,     0,   305,     0,   129,     0,   221,
-     223,    67,   176,     0,     0,     0,   136,   134,    65,     0,
-     123,   260,     0,     0,   190,     0,     0,     0,     0,     0,
-       0,     0,    67,     0,     0,   296,     0,     0,   129,   130,
-     129,     0,     0,     0,     0,     0,   323,   301,   302,   296,
-       0,   321,    67,   206,   175,   131,   137,   135,    64,   235,
-     237,   115,   132,     0,     0,   298,     0,   196,     0,     0,
-     192,   193,   189,     0,     0,   115,   115,     0,   303,   304,
-     317,   319,     0,     0,   306,   309,   310,     0,   129,    65,
-     133,   127,   194,   195,     0,     0,     0,     0,     0,     0,
-       0,   123,     0,   290,     0,   123,   322,   234,     0,   125,
-     191,   197,   198,     0,   283,     0,     0,   106,   108,   115,
-     115,     0,   115,   115,   291,   312,   128,     0,   240,   281,
-       0,   282,     0,   293,   292,     0,     0,     0,   126,     0,
-       0,     0,   115,   115,     0,     0,     0,   295,   294,   288,
-       0,     0,   287,     0,   284
+       0,     0,     0,     0,     0,   181,   180,   223,     0,   311,
+     289,    67,   280,   288,     0,     0,    55,     0,     0,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,     0,
+      53,    54,    49,    50,    51,    52,    39,    40,    41,    42,
+      43,    44,    45,    46,    47,    48,     0,     0,     0,   130,
+     130,   334,    67,    67,   325,     0,     0,     0,     0,     0,
+      67,    67,    67,    67,    67,     0,     0,     0,     0,     0,
+     107,   109,   108,   106,   110,   111,   112,   113,   114,   117,
+     165,   163,   152,   153,   154,   157,    66,   151,   225,   227,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,   171,   205,     0,     0,     0,   175,     0,   172,
+       0,     0,     0,   135,   244,   255,   256,   257,   262,   258,
+     259,   260,   261,   253,     0,     0,     0,     0,   271,   278,
+     277,   279,     0,     0,   290,     0,     0,    67,    67,    67,
+      67,     0,   330,     0,   332,   307,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+      67,     0,   115,   121,   120,   118,   119,   122,   123,   125,
+     135,   135,     0,     0,     0,     0,     0,   307,     0,     0,
+       0,     0,     0,     0,     0,   170,   156,   168,     0,   173,
+     174,     0,     0,     0,     0,   224,   243,   116,   241,     0,
+     254,     0,   265,     0,     0,     0,   268,     0,   266,   281,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+     338,     0,     0,     0,   321,   322,     0,     0,     0,     0,
+     339,     0,     0,     0,   319,     0,   130,     0,   226,   228,
+      67,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,   204,   177,     0,     0,     0,     0,     0,     0,
+     137,   135,    65,     0,   124,     0,   264,   156,     0,   263,
+     267,     0,     0,   306,     0,     0,     0,     0,   130,   131,
+     130,     0,     0,     0,     0,     0,     0,   337,   309,     0,
+      67,   313,   314,   306,     0,   335,    67,   211,     0,     0,
+       0,     0,   191,     0,     0,     0,     0,   202,     0,   176,
+       0,     0,    67,   132,   138,   136,    64,   240,   242,   116,
+     133,     0,   270,     0,     0,     0,   116,   116,     0,   315,
+     316,   317,   318,   331,   333,   308,     0,     0,   320,   323,
+     324,   310,     0,     0,   130,     0,     0,     0,     0,     0,
+     199,     0,     0,     0,   193,   194,   190,    65,   134,   128,
+     272,   269,     0,     0,     0,     0,   124,     0,   300,     0,
+     340,   124,   336,   195,   196,   197,   198,     0,     0,     0,
+     203,   239,     0,   126,     0,   293,     0,     0,   107,   109,
+     116,   116,     0,   116,   116,   301,   326,   192,   200,   201,
+     129,     0,   245,   291,     0,   292,     0,   303,   302,     0,
+       0,     0,   127,     0,     0,     0,   116,   116,     0,     0,
+       0,   305,   304,   298,     0,     0,   297,     0,   294
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
-      -1,   218,   219,   220,   301,   318,   164,   165,    78,   539,
-     113,    12,    79,    14,    15,    40,    41,    42,    47,    53,
-     118,   128,   369,   256,   437,   372,   608,   589,   412,   496,
-     571,   448,   497,    80,   166,   139,   156,   140,   141,   110,
-     324,   221,   325,   121,    87,   157,    16,    17,    18,    20,
-      19,   388,   438,   439,    62,    23,    60,   101,   451,   452,
-     129,   172,    54,    96,    55,    48,   290,   222,    82,   224,
-     332,   333,    56,    92,    93,   250,   596,   134,   346,   557,
-     456,   251,   252,   253,   254
+      -1,   272,   273,   274,   299,   316,   162,   163,    79,   587,
+     113,    12,    80,    14,    15,    41,    42,    43,    48,    54,
+     118,   128,   349,   233,   439,   352,   672,   653,   412,   530,
+     629,   465,   531,    81,   164,   137,   154,   138,   139,   110,
+     373,   398,   374,   121,    88,   155,    16,    17,    18,    20,
+      19,   383,   440,   441,    63,    23,    61,   101,   468,   469,
+     129,   170,    55,    96,    56,    49,   471,   399,    83,   401,
+     282,   283,    57,    92,    93,   227,   657,   132,   324,   598,
+     490,   500,   228,   229,   230,   231
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -524
+#define YYPACT_NINF -622
 static const yytype_int16 yypact[] =
 {
-     369,  -524,  -524,  -524,  -524,  -524,  -524,  -524,    46,  -130,
-      11,   -89,    62,   -59,   258,  -524,   135,   506,  -524,   227,
-     130,   -12,    26,  -524,    -1,   180,  -524,  1572,  -524,  -524,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-     119,   119,   250,  -524,  -524,  -524,  -524,   119,  -524,  -524,
-    -524,  -524,  -524,   119,    39,  -524,    -2,   214,   221,   229,
-    -524,  -524,  -524,  -524,  -524,    59,  -524,  -524,  -524,  -524,
-    -524,  -524,  -524,  -524,   262,   268,     8,    35,  -524,  -524,
-    -524,     9,  -524,   195,   195,   244,  -524,   162,   233,   233,
-     186,   238,  -524,   127,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,    50,  1126,  -524,   133,   161,   815,    59,  -524,     9,
-     -88,   172,  1126,   181,   162,   162,  -524,  -524,  1372,  -524,
-    -524,  1612,   337,  -524,  -524,  -524,  -524,  -524,  1652,  -524,
-      -3,   314,   906,  1867,  -524,   334,  -524,  -524,     9,  -524,
-     205,   208,  1692,  1692,   200,   -64,  1692,  -524,   359,   211,
-    -524,  1612,  1692,    59,   216,     9,   410,  -524,   223,   357,
-     361,   362,   363,   365,   275,   366,  1182,   329,  -524,    97,
-    -524,  -524,  -524,   906,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,  -524,   324,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,   511,   491,
-     234,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,  -524,  -524,   252,   253,   259,   260,  1612,   263,   267,
-     271,  -524,  -524,  -524,  -524,  -524,  -524,   354,  1732,    68,
-     374,   233,  -524,  -524,   511,   491,  1692,  1692,  1692,  1692,
-    1692,  1692,  1692,  1692,  1692,  1692,  1692,  1692,  1692,  1692,
-    -524,   233,  -524,   197,  -524,  -524,   210,  1452,  -524,   -31,
-       2,  -524,   264,     9,   237,  -524,   329,   -25,  1372,  -524,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    1412,  1772,   855,   403,  -524,  -524,  -524,   279,  -524,  -524,
-     405,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,   284,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,   285,  1612,
-    1612,  1612,  1612,  1612,  -524,   -46,  1612,  1612,  1612,  -524,
-      59,   766,  -524,   287,   906,   906,  -524,   906,  1652,  1692,
-    1692,    45,    51,  -524,   766,    17,   290,   294,   295,   297,
-     298,   299,    14,   766,   766,   417,  1652,  1692,  1692,   452,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,  -524,   189,  -524,  -524,  -524,  -524,   189,  -524,   181,
-     421,  -524,   102,  1080,   -32,  -524,   -49,  -524,   305,  1492,
-     306,  1612,  1612,  -524,   308,   311,   315,   316,  1612,  -524,
-     317,   318,   431,  -524,  1692,   319,  -524,   321,   906,   766,
-     766,    24,  -524,    28,  -524,  -524,   906,   320,  1692,  1692,
-    1692,  1692,  1692,   322,   325,   327,  1692,   906,   766,   328,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,   305,   305,
-    1692,  -524,   323,  1035,   -17,  -524,  -524,    30,  -524,  -524,
-       9,   331,   326,   462,   332,   333,   154,  1612,  1612,  1612,
-    1612,  -524,  1612,  1612,  1692,  -524,   472,   473,   340,   339,
-     341,   906,   493,   906,   347,   348,   906,   349,     9,  -524,
-     352,   353,   507,   906,   906,     9,   343,   360,  1692,  -524,
-    -524,    38,  -524,   371,   494,   515,  -524,   305,   115,  1532,
-    -524,  -524,  1612,  1612,  -524,  1692,   367,   368,   372,   379,
-     382,   385,    56,   906,   906,  1812,   906,   906,   360,  -524,
-     360,   906,   384,  1692,  1692,  1692,  -524,  -524,  -524,  1812,
-     487,  -524,   766,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-    -524,     9,    -6,   388,   389,  -524,  1612,  -524,  1612,  1612,
-    -524,  -524,  -524,   390,   386,    33,     9,   166,  -524,  -524,
-    -524,  -524,   383,   906,  -524,  -524,  -524,   170,   360,   115,
-    -524,   495,  -524,  -524,   396,   397,   399,   536,     3,   623,
-     623,  -524,  1852,  -524,   395,  -524,  -524,  -524,   552,   411,
-    -524,  -524,  -524,   906,  -524,  1323,     7,   412,   414,  -524,
-    -524,     6,    33,     9,  -524,   189,  -524,   540,  -524,  -524,
-     413,  -524,  1323,   210,   210,   550,   623,   623,  -524,   553,
-     416,   906,  -524,  -524,   906,   555,   500,   210,   210,  -524,
-     906,   557,  -524,   906,  -524
+     805,  -622,  -622,  -622,  -622,  -622,  -622,  -622,    -6,  -112,
+      23,   -97,    91,   -94,    24,  -622,   126,  1385,  -622,   135,
+     257,    48,    77,  -622,     3,   216,  -622,  1807,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+    -622,    49,    49,   187,  -622,  -622,  -622,  -622,    49,  -622,
+    -622,  -622,  -622,  -622,    49,   218,  -622,    16,   220,   239,
+     243,  -622,  -622,  -622,  -622,  -622,   110,  -622,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,   267,   271,     1,   691,  -622,
+    -622,  -622,   -28,  -622,   246,   246,   206,  -622,    46,   215,
+     215,  -622,  -622,   343,  -622,  -622,  -622,  -622,  -622,  -622,
+    -622,   -59,  1537,  -622,   121,   130,   880,   110,  -622,   -28,
+    -110,   138,  1537,   142,    46,    46,  -622,  -622,  1555,  -622,
+    -622,  1830,   302,  -622,  -622,  -622,  -622,  -622,  1848,  -622,
+     -14,  2199,  -622,   293,  -622,  -622,   -28,  -622,   160,   165,
+    1877,  1877,   168,  -103,  1877,  -622,   334,   189,  -622,  1830,
+    1877,   110,   191,   -28,   221,  -622,    85,   341,   342,   345,
+     354,   355,   323,   360,  1373,   315,  -622,    28,  -622,  -622,
+    -622,  -622,  -622,   316,  1921,    42,   361,   215,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,   393,   529,   393,   529,  1877,
+    1877,  1877,  1877,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,  1877,  1877,  1877,  1877,  1877,
+    1877,  1877,  1877,  1877,  1877,  1877,  1877,  -622,   215,  -622,
+      70,  -622,  -622,   176,  1578,  -622,   -39,   -46,  -622,   208,
+     -28,   223,  -622,   315,     5,  1555,  -622,  -622,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,   393,   529,   393,
+     529,   219,   227,   228,   234,   235,   241,   242,  1596,  2009,
+     993,   356,   244,   245,   251,  -622,  -622,  -622,   254,  -622,
+     110,   792,  -622,   240,   943,   943,  -622,   943,  1848,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  1877,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,  1877,  1877,  1877,    26,
+      58,  -622,   792,   -35,   252,   256,   258,   259,   260,   263,
+     792,   792,   792,   792,   792,   389,  1848,  1877,  1877,   375,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+    -622,  -622,   202,  -622,  -622,  -622,  -622,   202,  -622,   142,
+     390,   273,   274,   276,   277,  1830,  1830,  1830,  1830,  1830,
+    1830,  1830,  -622,  -622,    57,  1268,   -82,  -622,   -64,  -622,
+    1830,  1830,  1830,   275,  1628,  -622,  -622,  -622,  -622,  -622,
+    -622,  -622,  -622,   374,  1757,  2041,  1313,   414,  -622,  -622,
+    -622,  -622,  1877,   278,  -622,   279,   943,   792,   792,   792,
+     792,    31,  -622,    33,  -622,  -622,   943,   280,  1877,  1877,
+    1877,  1877,  1877,   281,   282,   284,   285,   287,  1877,   943,
+     792,   288,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+     275,   275,  1877,  1830,  1830,  1830,  1830,  -622,   290,   291,
+     292,   294,   282,   295,  1830,  -622,   286,  1222,   -62,  -622,
+    -622,   301,   307,   429,    20,  -622,  -622,   -28,   309,   312,
+    -622,   448,  -622,    87,  1508,   -10,  -622,   -61,  -622,  -622,
+     455,   456,   318,   317,   319,   320,   321,   943,   473,   943,
+     338,   339,   943,   340,   -28,  -622,   344,   346,   478,   496,
+     351,  1877,   943,   943,   -28,   348,   352,  1877,  -622,  -622,
+      -5,   353,   357,   359,   362,   115,  1830,  1830,  1830,  1830,
+     146,  1830,  -622,  -622,   336,  1830,  1830,  1877,   493,   515,
+    -622,   275,   530,  1789,  -622,   363,  -622,   358,   -60,  -622,
+    -622,   943,   943,  2082,   943,   943,   943,   943,   352,  -622,
+     352,  1877,   943,   364,  1877,  1877,  1877,  -622,  -622,   516,
+     792,  -622,  -622,  2082,   472,  -622,   792,  -622,  1830,  1830,
+    1830,  1830,  -622,   368,   377,   372,   376,  -622,   282,  -622,
+     379,   381,     2,  -622,  -622,  -622,  -622,  -622,  -622,   -28,
+       4,   517,  -622,   380,   382,   378,   -16,   -28,   157,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,   384,   943,  -622,  -622,
+    -622,  -622,   282,   178,   352,   386,   388,   394,   396,  1830,
+    -622,  1830,  1830,   198,  -622,  -622,  -622,   530,  -622,   507,
+    -622,  -622,   533,    -7,   641,   641,  -622,  2100,  -622,   398,
+     351,  -622,  -622,  -622,  -622,  -622,  -622,   406,   408,   409,
+    -622,  -622,   564,   417,   943,  -622,  1088,     7,   415,   416,
+    -622,  -622,   -12,   -16,   -28,  -622,   202,  -622,  -622,  -622,
+    -622,   548,  -622,  -622,   418,  -622,  1088,   176,   176,   557,
+     641,   641,  -622,   558,   419,   943,  -622,  -622,   943,   562,
+     508,   176,   176,  -622,   943,   563,  -622,   943,  -622
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -524,   443,   445,   446,   350,   346,  -229,  -524,     0,    16,
-    -141,   489,    13,  -524,  -524,  -524,  -524,    61,  -524,  -524,
-    -524,  -190,  -524,  -444,  -524,  -263,  -524,  -524,  -337,    41,
-    -524,  -407,  -524,  -524,   -24,   356,  -108,  -524,   474,   508,
-     -81,  -150,  -207,   228,   261,   351,  -524,  -524,   598,  -524,
-    -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,  -524,
-     527,  -524,  -524,  -524,  -524,  -524,  -524,  -523,   -70,   104,
-    -234,  -524,  -524,   566,  -524,  -524,  -524,  -524,  -524,    94,
-     209,  -524,  -524,  -524,  -524
+    -622,   451,   452,   454,  -163,  -157,  -174,  -622,     0,   -41,
+    -102,   494,    13,  -622,  -622,  -622,  -622,   222,  -622,  -622,
+    -622,  -145,  -622,  -427,  -622,  -227,  -622,  -622,  -301,    -2,
+    -622,  -412,  -622,  -622,   -26,   369,  -116,  -622,   477,   484,
+    -113,  -161,  -259,     8,   147,   347,  -622,  -622,   574,  -622,
+    -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,  -622,
+     503,  -622,  -622,  -622,  -622,  -622,  -622,  -621,  -121,    55,
+    -195,  -622,  -622,   537,  -622,  -622,  -622,  -622,  -622,    32,
+     151,  -445,  -622,  -622,  -622,  -622
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
    number is the opposite.  If zero, do what YYDEFACT says.
    If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -209
+#define YYTABLE_NINF -214
 static const yytype_int16 yytable[] =
 {
-      11,   337,   377,    81,   343,   414,   498,   347,   348,   349,
-     350,   351,   105,    13,   336,   355,   284,    11,   336,    90,
-     169,    63,    64,   111,    24,   170,   286,    94,   494,   111,
-      13,   489,   490,     1,     2,   471,     3,     4,     5,   473,
-     167,   338,    63,    64,   615,   107,    66,    67,    68,    69,
-      70,    71,    72,   109,     1,     2,   111,     3,     4,     5,
-      90,   356,   223,   111,   494,    26,    91,   146,   111,    25,
-     266,   111,   610,   382,   384,   386,   147,   472,   138,   334,
-      27,   472,   109,   495,    73,   335,   269,  -144,   138,   620,
-     537,   146,   111,    11,   155,    28,   285,   569,    21,   111,
-     262,    83,    84,   223,   155,   111,   398,    91,    88,   398,
-     111,   579,   580,    22,    89,   446,   399,     2,   259,   260,
-       4,   112,   263,   398,   429,   378,   379,   112,   267,   373,
-     445,   431,   432,   433,     1,    43,   434,     3,   398,     5,
-     435,   436,    57,   431,   432,   433,     1,   493,   434,     3,
-     531,     5,   435,   436,   112,   613,   614,    59,   616,   617,
-     171,   112,    95,   594,   374,   -67,   112,   611,   359,   112,
-     465,   106,    49,    50,    51,   416,   444,    52,   627,   628,
-      58,   560,   287,   561,   477,  -144,   479,   480,   481,  -144,
-     112,   533,    74,    75,   119,   120,    76,   112,    77,   108,
-     411,   -67,    61,   112,   331,   135,   413,   -67,   112,   552,
-     136,   102,   341,   342,   331,   344,   345,   331,   331,   331,
-     331,   331,   352,   353,   354,   331,   -55,   -55,   -55,   -55,
-     408,   586,    86,   138,   360,   361,    98,   542,   393,   394,
-     395,   396,   397,    99,   155,   400,   401,   402,   427,   270,
-     271,   100,   362,   363,   131,   364,   365,   398,   366,   367,
-     368,   223,   441,   359,   223,   223,   103,   223,    37,    38,
-      39,   545,   104,    45,   223,    46,   132,   288,   272,   273,
-     274,   275,   423,   223,   223,    85,   116,    86,   117,   564,
-     565,   566,   142,   284,   122,   123,   124,   125,   126,   127,
-      29,    30,    31,    32,    33,    34,    35,   504,    36,   505,
-     454,   455,   357,   358,   155,   409,   410,   461,   601,   581,
-     143,   582,   605,   585,   148,   582,   431,   432,   433,   360,
-     361,   434,   155,   428,   331,   435,   436,   150,   223,   223,
-     223,   168,   151,   152,   114,   115,   223,   362,   363,   595,
-     364,   365,   173,   366,   367,   368,   255,   223,   223,   443,
-     257,   258,   261,   264,   265,   450,   -56,   612,   268,  -208,
-     -57,   -60,   -59,   285,   -58,   276,   506,   507,   508,   509,
-     331,   510,   511,   111,   289,   336,   319,   -69,     1,     2,
-     376,     3,     4,     5,   331,   478,   331,   331,   331,     6,
-       7,   223,   485,   223,   320,   321,   223,    37,    38,    39,
-     329,   322,   323,   223,   223,   326,   491,    63,    64,   327,
-       8,   543,   544,   328,     9,   387,   375,   390,    10,     1,
-       2,   389,     3,     4,     5,   403,   391,   392,   405,   406,
-     512,   407,   404,   223,   223,   417,   223,   223,   415,   418,
-     419,   223,   420,   421,   422,   426,   430,   424,   425,   440,
-     447,   453,   223,   457,   532,   574,   458,   575,   576,   464,
-     459,   460,   462,   463,   466,   541,   467,   482,   476,   500,
-     483,   331,   484,   488,   501,   492,   499,   502,   503,   513,
-     514,   556,   515,   223,   516,   529,   517,   519,   538,   331,
-     331,   331,   505,   521,   523,   556,  -207,   524,   525,   223,
-     223,   526,   468,   469,   470,   530,   535,   302,   303,   536,
-     475,   547,   546,   223,   -69,     1,     2,   548,     3,     4,
-       5,   486,   487,   534,   549,   550,     6,     7,   551,   563,
-     472,   572,   573,   583,   578,   577,   223,   223,   588,   590,
-     591,   223,   592,   593,   223,   604,   606,     8,   603,   607,
-     223,     9,   618,   223,   -18,    10,   -19,   621,   619,   538,
-     624,   625,   630,   631,   633,   518,   247,   520,   248,   249,
-     522,   340,   133,   570,   339,   587,   149,   527,   528,   304,
-     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
-     315,   316,   317,   291,   292,   293,   294,   295,   296,   297,
-     298,   299,   300,   371,   145,    44,   130,   553,   554,   380,
-     558,   559,    97,   567,   474,   562,   174,   175,     0,     0,
-      63,    64,   176,     0,     0,     0,   568,     0,     0,     0,
-       0,     0,     1,     2,     0,     3,     4,     5,   177,   178,
-     179,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   180,   181,     0,     0,   584,     0,     0,
-       0,     0,     0,     0,     0,     0,   359,     0,     0,     0,
-       0,   182,     0,   599,   600,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,   609,   183,   184,
-     185,   186,   187,   188,   189,   190,   191,   192,   193,   194,
-     195,   196,   197,   198,   199,     0,     0,     0,     0,     0,
-     622,   623,     0,     0,     0,   626,     0,     0,   629,     0,
-       0,     0,     0,     0,   632,     0,     0,   634,     0,     0,
-     200,   201,   597,   598,   204,   205,   206,   207,   208,   209,
-     210,   211,   212,     0,   213,     0,   214,   215,   216,     0,
-     362,   363,     0,   364,   365,     0,   366,   367,   368,   174,
-     175,     0,     0,    63,    64,   176,     0,     0,     0,     0,
-       0,     0,     0,     0,   217,     1,     2,     0,     3,     4,
-       5,   177,   178,   179,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,   180,   181,     0,     0,
+      11,    82,   287,   275,   286,   105,   321,   520,   165,   111,
+     376,   378,   167,    13,   168,   357,   111,    11,   286,   414,
+     111,   325,   326,   327,   328,   329,   679,   111,   508,   509,
+      13,   335,   288,   246,   317,   674,   243,    91,   528,  -145,
+     532,   318,   487,   276,   489,    94,    24,    21,     2,   144,
+     111,     4,   109,   284,   528,   684,   144,   111,   145,   285,
+     111,    26,    22,   277,    28,   239,    29,    30,    31,    32,
+      33,    34,    35,    36,   529,    37,   136,   454,   119,   120,
+     109,   111,    25,   336,   459,   488,   136,   488,   -55,   -55,
+     -55,   -55,   153,    11,   361,   454,   363,   454,   454,   454,
+     133,   362,   153,   364,   460,   134,   524,   540,   593,    27,
+     112,   247,   248,   111,   236,   237,   458,   112,   240,   585,
+     354,   112,   149,   150,   244,   353,    44,   416,   112,   433,
+     434,   435,   -67,   623,   436,   473,   475,   477,   437,   438,
+    -145,   358,   359,   431,  -145,   433,   434,   435,   281,   454,
+     436,   112,   567,   169,   437,   438,   539,   655,   112,   626,
+     400,   112,   627,   400,   400,    60,   400,   640,   106,   634,
+     635,   675,   406,   319,   320,   281,   322,    38,    39,    40,
+     278,    46,   112,    47,    95,   411,   -67,   337,   338,   323,
+     281,   281,   281,   281,   281,   330,   331,   332,   333,   334,
+     281,   400,    38,    39,    40,   565,    58,   479,   136,   400,
+     400,   400,   400,   400,   112,   538,   454,   413,   -67,   153,
+     429,   455,    86,   493,    87,   495,   496,   497,    64,    65,
+     339,   114,   115,   677,   678,    59,   680,   681,    62,    91,
+       1,     2,    98,     3,     4,     5,   454,   603,   116,   604,
+     117,   536,   447,   448,   449,   450,   451,   452,   453,   691,
+     692,    99,   153,    84,    85,   100,   102,   461,   462,   463,
+      89,   103,   572,   407,   551,   104,    90,   122,   123,   124,
+     125,   126,   127,    87,   140,   400,   400,   400,   400,   400,
+     408,   409,   410,   141,   146,   400,   275,   340,   341,    50,
+      51,    52,   148,   577,    53,   559,   166,   590,   400,   400,
+     153,   430,   281,   642,   636,   232,   637,   342,   343,   234,
+     344,   345,   235,   346,   347,   348,   249,   250,   251,   252,
+     511,   512,   513,   514,   238,   641,   276,   637,   241,   403,
+     404,   522,   405,   433,   434,   435,   242,   245,   436,   457,
+     -56,   -57,   437,   438,   -60,   650,   605,   559,   467,   608,
+     609,   610,     1,   -59,   -58,     3,   400,     5,   400,   253,
+     111,   400,   286,   279,   355,   365,   281,   415,   379,   432,
+     356,   400,   400,   366,   367,   423,   424,   425,   426,   427,
+     368,   369,   281,   494,   281,   281,   281,   370,   371,   402,
+     380,   381,   504,   573,   574,   575,   576,   382,   578,   662,
+     384,   417,   580,   581,   666,   418,   510,   419,   420,   421,
+     400,   400,   422,   400,   400,   400,   400,   428,   442,   443,
+     444,   400,   445,   446,   464,   470,   478,   480,   481,   400,
+     498,   499,   492,   501,   502,   400,   503,   507,   457,   516,
+     517,   518,   523,   519,   521,   615,   616,   617,   618,   656,
+     525,   482,   483,   484,   485,   486,   526,   527,   533,   534,
+     535,   491,   541,   542,   543,   560,   544,   549,   545,   546,
+     547,   566,   557,   676,   505,   506,   400,   289,   290,   291,
+     292,   293,   294,   295,   296,   297,   298,   551,   552,   554,
+     558,   582,   579,   555,   563,   556,   647,   589,   648,   649,
+     559,   564,   568,   400,   400,   583,   569,   597,   570,   584,
+     611,   571,   591,   607,   592,   281,   488,   619,   281,   281,
+     281,   621,   586,   400,   620,   622,   624,   597,   625,   630,
+     633,   632,   548,   643,   550,   644,   631,   553,   638,     1,
+     654,   645,     3,   646,     5,   300,   301,   561,   562,   400,
+     400,   652,   665,   667,   400,   668,   669,   400,   670,   671,
+     682,   -18,   -19,   400,   685,   688,   400,   683,   689,   694,
+     697,   695,   224,   225,   339,   226,   651,   131,   628,   147,
+     143,    45,   360,   130,    97,   613,   594,   595,   515,   599,
+     600,   601,   602,   351,     0,     0,     0,   606,     0,     0,
+       0,   664,     0,     0,     0,   612,     0,     0,     0,     0,
+       0,   614,     0,     0,     0,     0,     0,   586,     0,   302,
+     303,   304,   305,   306,   307,   308,   309,   310,   311,   312,
+     313,   314,   315,     0,   385,   386,     0,     0,    64,    65,
+     387,   340,   341,     0,     0,     0,     0,     0,     0,     0,
+       1,     2,   639,     3,     4,     5,   388,   389,   390,     0,
+       0,   342,   343,     0,   344,   345,     0,   346,   347,   348,
+       0,   391,   392,     0,     0,     0,     0,     0,     0,   660,
+     661,     0,     0,     0,     0,   339,     0,     0,    64,    65,
+     393,   107,    67,    68,    69,    70,    71,    72,    73,   673,
+       1,     2,     0,     3,     4,     5,   180,   181,   182,   183,
+     184,   185,   186,   187,   188,   189,   190,   191,   192,   193,
+     194,   257,   258,   259,   260,   686,   687,     0,     0,     0,
+     690,    74,     0,   693,     0,     0,     0,     0,     0,   696,
+       0,     0,   698,     0,     0,     0,     0,     0,     0,     0,
+     261,   203,   658,   659,   206,   207,   208,   209,   210,   211,
+     212,   213,   214,     0,   262,     0,   263,   264,   265,     0,
+     266,   267,   342,   343,     0,   344,   345,     0,   346,   347,
+     348,     0,     0,     0,     0,   385,   386,     0,     0,    64,
+      65,   387,     0,   394,     0,  -213,   395,     0,   396,     0,
+     397,     1,     2,     0,     3,     4,     5,   388,   389,   390,
+       0,     0,     0,   -69,     1,     2,     0,     3,     4,     5,
+       0,     0,   391,   392,     0,     6,     7,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   111,     0,     0,
+       0,   393,    75,    76,     0,     0,    77,     8,    78,   108,
+       0,     9,     0,     0,     0,    10,     0,   180,   181,   182,
+     183,   184,   185,   186,   187,   188,   189,   190,   191,   192,
+     193,   194,   257,   258,   259,   260,     0,    64,    65,     0,
+     107,    67,    68,    69,    70,    71,    72,    73,     0,     1,
+       2,     0,     3,     4,     5,     0,     0,     0,     0,     0,
+       0,   261,   203,   204,   205,   206,   207,   208,   209,   210,
+     211,   212,   213,   214,     0,   262,     0,   263,   264,   265,
+      74,   266,   267,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,   385,   386,   112,     0,
+      64,    65,   387,     0,   394,     0,     0,   395,     0,   396,
+       0,   397,     1,     2,     0,     3,     4,     5,   388,   389,
+     390,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,   391,   392,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-     111,     0,    63,    64,   182,   107,    66,    67,    68,    69,
-      70,    71,    72,     0,     1,     2,     0,     3,     4,     5,
-       0,   183,   184,   185,   186,   187,   188,   189,   190,   191,
-     192,   193,   194,   195,   196,   197,   198,   199,     0,     0,
-       0,     0,    63,    64,    73,   107,   158,   159,   160,   161,
-     162,   163,    72,     0,     1,     2,     0,     3,     4,     5,
-       0,     0,     0,   200,   201,   202,   203,   204,   205,   206,
-     207,   208,   209,   210,   211,   212,     0,   213,     0,   214,
-     215,   216,     0,     0,    73,     0,     0,     0,     0,   174,
-     175,     0,     0,    63,    64,   176,     0,     0,   112,     0,
-       0,     0,     0,     0,     0,     1,     2,   217,     3,     4,
-       5,   177,   178,   179,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,   180,   181,     0,     0,
+      64,    65,   393,   107,   156,   157,   158,   159,   160,   161,
+      73,     0,     1,     2,     0,     3,     4,     5,   180,   181,
+     182,   183,   184,   185,   186,   187,   188,   189,   190,   191,
+     192,   193,   194,   257,   258,   259,   260,     0,     0,     0,
+       0,    75,    76,    74,     0,    77,     0,    78,   142,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,   182,     0,     0,     0,     0,     0,
-       0,     0,    74,    75,     0,     0,    76,     0,    77,   144,
-       0,   183,   184,   185,   186,   187,   188,   189,   190,   191,
-     192,   193,   194,   195,   196,   197,   198,   199,     0,     0,
+       0,     0,   261,   203,   204,   205,   206,   207,   208,   209,
+     210,   211,   212,   213,   214,     0,   262,     0,   263,   264,
+     265,     0,   266,   267,     0,     0,     0,     0,     0,     0,
+       0,   385,   386,     0,     0,     0,     0,   387,     0,     0,
+       0,     0,     0,     0,     0,   394,     0,     0,   395,     0,
+     396,     0,   397,   388,   389,   390,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   391,   392,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,    74,    75,     0,     0,    76,     0,    77,   385,
-       0,     0,     0,   200,   201,   202,   203,   204,   205,   206,
-     207,   208,   209,   210,   211,   212,     0,   213,     0,   214,
-     215,   216,    63,    64,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     1,     2,     0,     3,     4,     5,
-     277,     0,     0,     0,     0,     0,     0,   217,     0,     0,
-       0,     0,     0,     0,     0,   278,   279,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,    63,    64,   111,
-     107,   158,   159,   160,   161,   162,   163,    72,     0,     1,
-       2,     0,     3,     4,     5,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   393,     0,     0,
+       0,     0,     0,     0,    75,    76,     0,     0,    77,     0,
+      78,   377,     0,   180,   181,   182,   183,   184,   185,   186,
+     187,   188,   189,   190,   191,   192,   193,   194,   257,   258,
+     259,   260,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   261,   203,   204,
+     205,   206,   207,   208,   209,   210,   211,   212,   213,   214,
+       0,   262,     0,   263,   264,   265,     0,   266,   267,    64,
+      65,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     1,     2,     0,     3,     4,     5,   254,     0,     0,
+     394,     0,     0,   395,     0,   396,     0,   397,     0,     0,
+       0,     0,   255,   256,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    64,    65,   111,   107,   156,
+     157,   158,   159,   160,   161,    73,     0,     1,     2,     0,
+       3,     4,     5,     0,     0,     0,     0,   180,   181,   182,
      183,   184,   185,   186,   187,   188,   189,   190,   191,   192,
-     193,   194,   195,   196,   197,   198,   199,     0,     0,    73,
-       0,     0,     0,    63,    64,     0,   107,    66,    67,    68,
-      69,    70,    71,    72,     0,     1,     2,     0,     3,     4,
-       5,     0,   200,   201,   202,   203,   204,   205,   206,   207,
-     208,   209,   210,   211,   212,   137,   213,     0,   214,   215,
-     216,     0,     0,     0,     0,    73,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,   112,     0,    63,
-      64,   -67,     0,   280,     0,     0,   281,     0,   282,     0,
-     283,     1,     2,     0,     3,     4,     5,   277,     0,     0,
+     193,   194,   257,   258,   259,   260,     0,     0,    74,     0,
+      64,    65,     0,   107,   156,   157,   158,   159,   160,   161,
+      73,     0,     1,     2,     0,     3,     4,     5,     0,     0,
+       0,   261,   203,   204,   205,   206,   207,   208,   209,   210,
+     211,   212,   213,   214,     0,   262,     0,   263,   264,   265,
+       0,   266,   267,    74,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   112,     0,
+      64,    65,   -67,     0,   268,  -212,     0,   269,     0,   270,
+       0,   271,     1,     2,     0,     3,     4,     5,   254,     0,
+       0,     0,     0,   -69,     1,     2,     0,     3,     4,     5,
+       0,     0,     0,   255,   256,     6,     7,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,   111,    75,
+      76,     0,     0,    77,     0,    78,   456,     8,     0,     0,
+       0,     9,     0,     0,     0,    10,     0,     0,   180,   181,
+     182,   183,   184,   185,   186,   187,   188,   189,   190,   191,
+     192,   193,   194,   257,   258,   259,   260,     0,     0,     0,
+       0,     0,     0,     0,    75,    76,     0,     0,    77,     0,
+      78,   476,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,   261,   203,   204,   205,   206,   207,   208,   209,
+     210,   211,   212,   213,   214,     0,   262,     0,   263,   264,
+     265,     0,   266,   267,     0,    64,    65,     0,   107,   156,
+     157,   158,   159,   160,   161,    73,     0,     1,     2,   112,
+       3,     4,     5,     0,     0,   268,     0,     0,   269,     0,
+     270,     0,   271,     0,    64,    65,     0,   107,    67,    68,
+      69,    70,    71,    72,    73,     0,     1,     2,    74,     3,
+       4,     5,    64,    65,     0,   151,    67,    68,    69,    70,
+      71,    72,    73,     0,     1,     2,   135,     3,     4,     5,
+       0,     0,     0,     0,     0,    64,    65,    74,   107,    67,
+      68,    69,    70,    71,    72,    73,     0,     1,     2,     0,
+       3,     4,     5,    64,    65,    74,   107,   156,   157,   158,
+     159,   160,   161,    73,     0,     1,     2,   350,     3,     4,
+       5,     0,     0,     0,     0,     0,     0,     0,    74,     0,
+       0,     0,     0,     0,     0,    64,    65,     0,   107,    67,
+      68,    69,    70,    71,    72,    73,    74,     1,     2,     0,
+       3,     4,     5,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   466,     0,    75,
+      76,     0,     0,    77,     0,    78,   537,     0,    74,     0,
+     152,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    75,    76,
+       0,     0,    77,     0,    78,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,    75,    76,     0,     0,
+      77,     0,    78,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    75,
+      76,     0,     0,    77,     0,    78,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    75,    76,     0,
+     372,    77,     0,    78,    64,    65,     0,   107,   156,   157,
+     158,   159,   160,   161,    73,     0,     1,     2,     0,     3,
+       4,     5,     0,     0,     0,     0,     0,     0,     0,    75,
+      76,     0,     0,    77,     0,    78,    64,    65,     0,   107,
+      67,    68,    69,    70,    71,    72,    73,    74,     1,     2,
+       0,     3,     4,     5,    64,    65,     0,    66,    67,    68,
+      69,    70,    71,    72,    73,     0,     1,     2,   588,     3,
+       4,     5,     0,     0,     0,     0,     0,    64,    65,    74,
+     107,   156,   157,   158,   159,   160,   161,    73,     0,     1,
+       2,     0,     3,     4,     5,    64,    65,    74,   151,    67,
+      68,    69,    70,    71,    72,    73,     0,     1,     2,     0,
+       3,     4,     5,     0,     0,     0,     0,     0,     0,     0,
+      74,     0,     0,     0,    64,    65,     0,   107,    67,    68,
+      69,    70,    71,    72,    73,     0,     1,     2,    74,     3,
+       4,     5,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    75,    76,
+       0,   472,    77,     0,    78,     0,     0,    74,    64,    65,
+       0,   280,    67,    68,    69,    70,    71,    72,    73,     0,
+       1,     2,     0,     3,     4,     5,     0,     0,     0,     0,
+      75,    76,     0,     0,    77,     0,    78,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    75,    76,
+       0,    74,    77,     0,    78,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,    75,    76,     0,     0,    77,     0,    78,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    75,
+      76,     0,     0,    77,     0,    78,    64,    65,     0,   107,
+     156,   157,   158,   159,   160,   161,    73,     0,     1,     2,
+       0,     3,     4,     5,     0,     0,     0,     0,    75,    76,
+       0,     0,    77,     0,    78,     0,     0,     0,    64,    65,
+       0,   107,   156,   157,   158,   159,   160,   161,    73,    74,
+       1,     2,     0,     3,     4,     5,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,    75,    76,     0,     0,    77,     0,    78,    64,
+      65,    74,   107,    67,    68,    69,    70,    71,    72,   596,
+       0,     1,     2,     0,     3,     4,     5,    64,    65,     0,
+     107,    67,    68,    69,    70,    71,    72,   663,     0,     1,
+       2,     0,     3,     4,     5,     0,     0,     0,     0,     0,
+       0,     0,    74,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+      74,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,   278,   279,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,   111,    74,    75,     0,
-       0,    76,     0,    77,   442,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,   183,   184,   185,
+      75,    76,     0,     0,    77,     0,   375,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,    75,    76,     0,     0,    77,     0,   474,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,   171,     0,     0,     0,     0,
+       0,     0,     0,    75,    76,     0,     0,    77,     0,    78,
+       0,     0,     0,     0,     0,     0,   172,   173,     0,     0,
+       0,    75,    76,     0,     0,    77,     0,    78,   174,   175,
+     176,   177,   178,   179,   180,   181,   182,   183,   184,   185,
      186,   187,   188,   189,   190,   191,   192,   193,   194,   195,
-     196,   197,   198,   199,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,    74,    75,     0,     0,    76,     0,    77,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,   200,
-     201,   202,   203,   204,   205,   206,   207,   208,   209,   210,
-     211,   212,     0,   213,     0,   214,   215,   216,     0,     0,
-       0,     0,     0,     0,     0,     0,   174,   175,     0,     0,
-       0,     0,   176,     0,   112,     0,     0,     0,     0,     0,
-     280,     0,     0,   281,     0,   282,     0,   283,   177,   178,
-     179,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   180,   181,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    63,
-      64,   182,   153,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,   183,   184,
-     185,   186,   187,   188,   189,   190,   191,   192,   193,   194,
-     195,   196,   197,   198,   199,     0,     0,     0,     0,    63,
-      64,    73,   107,   158,   159,   160,   161,   162,   163,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-     200,   201,   202,   203,   204,   205,   206,   207,   208,   209,
-     210,   211,   212,     0,   213,     0,   214,   215,   216,    63,
-      64,    73,   107,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,   217,     0,     0,     0,     0,     0,
-       0,   370,     0,     0,     0,   154,     0,     0,     0,    63,
-      64,    73,   107,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,   449,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   107,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,   540,   381,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,    65,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   107,   158,   159,   160,   161,   162,   163,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   153,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   107,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   330,    66,    67,    68,    69,    70,    71,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   107,   158,   159,   160,   161,   162,   163,    72,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   107,    66,    67,    68,    69,    70,    71,   555,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,    63,
-      64,    73,   107,    66,    67,    68,    69,    70,    71,   602,
-       0,     1,     2,     0,     3,     4,     5,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,     0,
-       0,    73,     0,   225,     0,     0,     0,     0,     0,     0,
+     196,   197,   198,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   226,   227,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,   383,   228,   229,   230,   231,
-     232,   233,   183,   184,   185,   186,   187,   188,   189,   190,
-     191,   192,   193,   194,   195,   196,   197,   234,   235,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77,     0,     0,     0,   236,
-     237,   238,     0,     0,   239,   201,   202,   203,   204,   205,
-     206,   207,   208,   209,   210,   211,   212,   240,   241,   242,
-     243,   244,   245,   246,     0,     0,     0,     0,     0,    74,
-      75,     0,     0,    76,     0,    77
+       0,     0,     0,   199,   200,   201,     0,     0,   202,   203,
+     204,   205,   206,   207,   208,   209,   210,   211,   212,   213,
+     214,   215,   216,   217,   218,   219,   220,   221,   222,   223
 };
 
 static const yytype_int16 yycheck[] =
 {
-       0,   230,   265,    27,   238,   342,   450,   241,   242,   243,
-     244,   245,     4,     0,    11,   249,   166,    17,    11,    21,
-     128,     7,     8,    54,   154,    28,   167,    29,    34,    54,
-      17,   438,   439,    19,    20,    11,    22,    23,    24,    11,
-     121,   231,     7,     8,    38,    10,    11,    12,    13,    14,
-      15,    16,    17,    77,    19,    20,    54,    22,    23,    24,
-      21,   251,   132,    54,    34,   154,    68,   155,    54,    58,
-     151,    54,   595,   280,   281,   282,   164,    53,   102,    11,
-      18,    53,   106,    53,    49,    17,   156,    54,   112,   612,
-     497,   155,    54,    93,   118,   154,   166,   541,    52,    54,
-     164,    40,    41,   173,   128,    54,   155,    68,    47,   155,
-      54,   555,   556,    67,    53,   164,   162,    20,   142,   143,
-      23,   152,   146,   155,   358,   266,   267,   152,   152,   160,
-     162,   137,   138,   139,    19,     0,   142,    22,   155,    24,
-     146,   147,   154,   137,   138,   139,    19,   164,   142,    22,
-     487,    24,   146,   147,   152,   599,   600,   158,   602,   603,
-     163,   152,   164,   160,   162,   156,   152,   160,    53,   152,
-     404,   163,    42,    43,    44,   158,   383,    47,   622,   623,
-     154,   518,   169,   520,   418,   152,   420,   421,   422,   156,
-     152,   153,   157,   158,    32,    33,   161,   152,   163,   164,
-     155,   156,    22,   152,   228,   155,   155,   156,   152,   153,
-     160,   152,   236,   237,   238,   239,   240,   241,   242,   243,
-     244,   245,   246,   247,   248,   249,     3,     4,     5,     6,
-     338,   568,    37,   257,   119,   120,    22,   500,   319,   320,
-     321,   322,   323,    22,   268,   326,   327,   328,   356,    26,
-      27,    22,   137,   138,    68,   140,   141,   155,   143,   144,
-     145,   331,   160,    53,   334,   335,     4,   337,   149,   150,
-     151,   505,     4,    46,   344,    48,    38,   173,     3,     4,
-       5,     6,   352,   353,   354,    35,    42,    37,    44,   523,
-     524,   525,   159,   443,    61,    62,    63,    64,    65,    66,
-      42,    43,    44,    45,    46,    47,    48,   153,    50,   155,
-     391,   392,   115,   116,   338,   339,   340,   398,   581,   153,
-     159,   155,   585,   153,   152,   155,   137,   138,   139,   119,
-     120,   142,   356,   357,   358,   146,   147,   156,   408,   409,
-     410,     4,   114,   115,    83,    84,   416,   137,   138,   578,
-     140,   141,    38,   143,   144,   145,    22,   427,   428,   383,
-     155,   153,   162,     4,   153,   389,     9,   596,   152,     0,
-       9,     9,     9,   443,     9,     9,   457,   458,   459,   460,
-     404,   462,   463,    54,    60,    11,   152,    18,    19,    20,
-     153,    22,    23,    24,   418,   419,   420,   421,   422,    30,
-      31,   471,   426,   473,   152,   152,   476,   149,   150,   151,
-      56,   152,   152,   483,   484,   152,   440,     7,     8,   152,
-      51,   502,   503,   152,    55,    22,   162,    22,    59,    19,
-      20,   152,    22,    23,    24,   331,   152,   152,   334,   335,
-     464,   337,   155,   513,   514,   155,   516,   517,   344,   155,
-     155,   521,   155,   155,   155,    38,     4,   353,   354,    38,
-     155,   155,   532,   155,   488,   546,   155,   548,   549,    38,
-     155,   155,   155,   155,   155,   499,   155,   155,   158,   153,
-     155,   505,   155,   155,    22,   162,   155,   155,   155,    17,
-      17,   515,   152,   563,   155,   152,   155,     4,   498,   523,
-     524,   525,   155,   155,   155,   529,     0,   155,   155,   579,
-     580,     4,   408,   409,   410,   155,    22,    26,    27,     4,
-     416,   153,   155,   593,    18,    19,    20,   155,    22,    23,
-      24,   427,   428,   162,   155,   153,    30,    31,   153,   155,
-      53,   153,   153,   160,   158,   155,   616,   617,    53,   153,
-     153,   621,   153,    17,   624,   160,     4,    51,   582,   148,
-     630,    55,    22,   633,   152,    59,   152,    17,   155,   569,
-      17,   155,    17,    73,    17,   471,   133,   473,   133,   133,
-     476,   235,    93,   542,   234,   569,   112,   483,   484,    98,
-      99,   100,   101,   102,   103,   104,   105,   106,   107,   108,
-     109,   110,   111,    92,    93,    94,    95,    96,    97,    98,
-      99,   100,   101,   257,   106,    17,    89,   513,   514,   268,
-     516,   517,    56,   529,   415,   521,     3,     4,    -1,    -1,
-       7,     8,     9,    -1,    -1,    -1,   532,    -1,    -1,    -1,
-      -1,    -1,    19,    20,    -1,    22,    23,    24,    25,    26,
+       0,    27,   176,   164,    11,     4,   201,   452,   121,    55,
+     269,   270,   128,     0,    28,   242,    55,    17,    11,   320,
+      55,   216,   217,   218,   219,   220,    38,    55,   440,   441,
+      17,   226,   177,   154,   197,   656,   149,    21,    34,    55,
+     467,   198,    11,   164,    11,    29,   158,    53,    20,   159,
+      55,    23,    78,    11,    34,   676,   159,    55,   168,    17,
+      55,   158,    68,   165,   158,   168,    42,    43,    44,    45,
+      46,    47,    48,    49,    54,    51,   102,   159,    32,    33,
+     106,    55,    59,   228,   166,    54,   112,    54,     3,     4,
+       5,     6,   118,    93,   257,   159,   259,   159,   159,   159,
+     159,   258,   128,   260,   168,   164,   168,   168,   168,    18,
+     156,    26,    27,    55,   140,   141,   375,   156,   144,   531,
+     166,   156,   114,   115,   150,   164,     0,   162,   156,   141,
+     142,   143,   160,   578,   146,   394,   395,   396,   150,   151,
+     156,   243,   244,   338,   160,   141,   142,   143,   174,   159,
+     146,   156,   157,   167,   150,   151,   166,   164,   156,   157,
+     281,   156,   589,   284,   285,   162,   287,   612,   167,   596,
+     597,   164,   288,   199,   200,   201,   202,   153,   154,   155,
+     167,    46,   156,    48,   168,   159,   160,   117,   118,   215,
+     216,   217,   218,   219,   220,   221,   222,   223,   224,   225,
+     226,   322,   153,   154,   155,   506,   158,   402,   234,   330,
+     331,   332,   333,   334,   156,   474,   159,   159,   160,   245,
+     336,   164,    35,   418,    37,   420,   421,   422,     7,     8,
+      54,    84,    85,   660,   661,   158,   663,   664,    22,    21,
+      19,    20,    22,    22,    23,    24,   159,   548,    42,   550,
+      44,   164,   365,   366,   367,   368,   369,   370,   371,   686,
+     687,    22,   288,    41,    42,    22,   156,   380,   381,   382,
+      48,     4,   157,   299,   159,     4,    54,    62,    63,    64,
+      65,    66,    67,    37,   163,   406,   407,   408,   409,   410,
+     316,   317,   318,   163,   156,   416,   457,   121,   122,    42,
+      43,    44,   160,   157,    47,   159,     4,   534,   429,   430,
+     336,   337,   338,   614,   157,    22,   159,   141,   142,   159,
+     144,   145,   157,   147,   148,   149,     3,     4,     5,     6,
+     443,   444,   445,   446,   166,   157,   457,   159,     4,   284,
+     285,   454,   287,   141,   142,   143,   157,   156,   146,   375,
+       9,     9,   150,   151,     9,   157,   551,   159,   384,   554,
+     555,   556,    19,     9,     9,    22,   487,    24,   489,     9,
+      55,   492,    11,    57,   166,   156,   402,   322,    22,     4,
+     157,   502,   503,   156,   156,   330,   331,   332,   333,   334,
+     156,   156,   418,   419,   420,   421,   422,   156,   156,   159,
+     156,   156,   428,   516,   517,   518,   519,   156,   521,   636,
+     156,   159,   525,   526,   641,   159,   442,   159,   159,   159,
+     541,   542,   159,   544,   545,   546,   547,    38,    38,   156,
+     156,   552,   156,   156,   159,    61,    22,   159,   159,   560,
+     159,   159,   162,   159,   159,   566,   159,   159,   474,   159,
+     159,   159,   166,   159,   159,   568,   569,   570,   571,   633,
+     159,   406,   407,   408,   409,   410,   159,    38,   159,   157,
+      22,   416,    17,    17,   156,   501,   159,     4,   159,   159,
+     159,   507,     4,   657,   429,   430,   607,    94,    95,    96,
+      97,    98,    99,   100,   101,   102,   103,   159,   159,   159,
+       4,   527,   166,   159,   156,   159,   619,   533,   621,   622,
+     159,   159,   159,   634,   635,    22,   159,   543,   159,     4,
+       4,   159,   159,   159,   166,   551,    54,   159,   554,   555,
+     556,   159,   532,   654,   157,   159,   157,   563,   157,    22,
+     162,   159,   487,   157,   489,   157,   166,   492,   164,    19,
+      17,   157,    22,   157,    24,    26,    27,   502,   503,   680,
+     681,    54,   164,   157,   685,   157,   157,   688,     4,   152,
+      22,   156,   156,   694,    17,    17,   697,   159,   159,    17,
+      17,    73,   131,   131,    54,   131,   627,    93,   590,   112,
+     106,    17,   245,    90,    57,   563,   541,   542,   447,   544,
+     545,   546,   547,   234,    -1,    -1,    -1,   552,    -1,    -1,
+      -1,   637,    -1,    -1,    -1,   560,    -1,    -1,    -1,    -1,
+      -1,   566,    -1,    -1,    -1,    -1,    -1,   627,    -1,   100,
+     101,   102,   103,   104,   105,   106,   107,   108,   109,   110,
+     111,   112,   113,    -1,     3,     4,    -1,    -1,     7,     8,
+       9,   121,   122,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      19,    20,   607,    22,    23,    24,    25,    26,    27,    -1,
+      -1,   141,   142,    -1,   144,   145,    -1,   147,   148,   149,
+      -1,    40,    41,    -1,    -1,    -1,    -1,    -1,    -1,   634,
+     635,    -1,    -1,    -1,    -1,    54,    -1,    -1,     7,     8,
+      59,    10,    11,    12,    13,    14,    15,    16,    17,   654,
+      19,    20,    -1,    22,    23,    24,    75,    76,    77,    78,
+      79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
+      89,    90,    91,    92,    93,   680,   681,    -1,    -1,    -1,
+     685,    50,    -1,   688,    -1,    -1,    -1,    -1,    -1,   694,
+      -1,    -1,   697,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+     119,   120,   121,   122,   123,   124,   125,   126,   127,   128,
+     129,   130,   131,    -1,   133,    -1,   135,   136,   137,    -1,
+     139,   140,   141,   142,    -1,   144,   145,    -1,   147,   148,
+     149,    -1,    -1,    -1,    -1,     3,     4,    -1,    -1,     7,
+       8,     9,    -1,   162,    -1,     0,   165,    -1,   167,    -1,
+     169,    19,    20,    -1,    22,    23,    24,    25,    26,    27,
+      -1,    -1,    -1,    18,    19,    20,    -1,    22,    23,    24,
+      -1,    -1,    40,    41,    -1,    30,    31,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,
+      -1,    59,   161,   162,    -1,    -1,   165,    52,   167,   168,
+      -1,    56,    -1,    -1,    -1,    60,    -1,    75,    76,    77,
+      78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
+      88,    89,    90,    91,    92,    93,    -1,     7,     8,    -1,
+      10,    11,    12,    13,    14,    15,    16,    17,    -1,    19,
+      20,    -1,    22,    23,    24,    -1,    -1,    -1,    -1,    -1,
+      -1,   119,   120,   121,   122,   123,   124,   125,   126,   127,
+     128,   129,   130,   131,    -1,   133,    -1,   135,   136,   137,
+      50,   139,   140,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,     3,     4,   156,    -1,
+       7,     8,     9,    -1,   162,    -1,    -1,   165,    -1,   167,
+      -1,   169,    19,    20,    -1,    22,    23,    24,    25,    26,
       27,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    40,    41,    -1,    -1,   563,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    53,    -1,    -1,    -1,
-      -1,    58,    -1,   579,   580,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,   593,    75,    76,
-      77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
-      87,    88,    89,    90,    91,    -1,    -1,    -1,    -1,    -1,
-     616,   617,    -1,    -1,    -1,   621,    -1,    -1,   624,    -1,
-      -1,    -1,    -1,    -1,   630,    -1,    -1,   633,    -1,    -1,
-     117,   118,   119,   120,   121,   122,   123,   124,   125,   126,
-     127,   128,   129,    -1,   131,    -1,   133,   134,   135,    -1,
-     137,   138,    -1,   140,   141,    -1,   143,   144,   145,     3,
-       4,    -1,    -1,     7,     8,     9,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   161,    19,    20,    -1,    22,    23,
-      24,    25,    26,    27,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    40,    41,    -1,    -1,
+      -1,    -1,    -1,    40,    41,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      54,    -1,     7,     8,    58,    10,    11,    12,    13,    14,
-      15,    16,    17,    -1,    19,    20,    -1,    22,    23,    24,
-      -1,    75,    76,    77,    78,    79,    80,    81,    82,    83,
-      84,    85,    86,    87,    88,    89,    90,    91,    -1,    -1,
-      -1,    -1,     7,     8,    49,    10,    11,    12,    13,    14,
-      15,    16,    17,    -1,    19,    20,    -1,    22,    23,    24,
-      -1,    -1,    -1,   117,   118,   119,   120,   121,   122,   123,
-     124,   125,   126,   127,   128,   129,    -1,   131,    -1,   133,
-     134,   135,    -1,    -1,    49,    -1,    -1,    -1,    -1,     3,
-       4,    -1,    -1,     7,     8,     9,    -1,    -1,   152,    -1,
-      -1,    -1,    -1,    -1,    -1,    19,    20,   161,    22,    23,
-      24,    25,    26,    27,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    40,    41,    -1,    -1,
+       7,     8,    59,    10,    11,    12,    13,    14,    15,    16,
+      17,    -1,    19,    20,    -1,    22,    23,    24,    75,    76,
+      77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
+      87,    88,    89,    90,    91,    92,    93,    -1,    -1,    -1,
+      -1,   161,   162,    50,    -1,   165,    -1,   167,   168,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    58,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,   157,   158,    -1,    -1,   161,    -1,   163,   164,
-      -1,    75,    76,    77,    78,    79,    80,    81,    82,    83,
-      84,    85,    86,    87,    88,    89,    90,    91,    -1,    -1,
+      -1,    -1,   119,   120,   121,   122,   123,   124,   125,   126,
+     127,   128,   129,   130,   131,    -1,   133,    -1,   135,   136,
+     137,    -1,   139,   140,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,     3,     4,    -1,    -1,    -1,    -1,     9,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,   162,    -1,    -1,   165,    -1,
+     167,    -1,   169,    25,    26,    27,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    40,    41,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,   157,   158,    -1,    -1,   161,    -1,   163,   164,
-      -1,    -1,    -1,   117,   118,   119,   120,   121,   122,   123,
-     124,   125,   126,   127,   128,   129,    -1,   131,    -1,   133,
-     134,   135,     7,     8,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    19,    20,    -1,    22,    23,    24,
-      25,    -1,    -1,    -1,    -1,    -1,    -1,   161,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    40,    41,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,     7,     8,    54,
-      10,    11,    12,    13,    14,    15,    16,    17,    -1,    19,
-      20,    -1,    22,    23,    24,    -1,    -1,    -1,    -1,    -1,
-      75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
-      85,    86,    87,    88,    89,    90,    91,    -1,    -1,    49,
-      -1,    -1,    -1,     7,     8,    -1,    10,    11,    12,    13,
-      14,    15,    16,    17,    -1,    19,    20,    -1,    22,    23,
-      24,    -1,   117,   118,   119,   120,   121,   122,   123,   124,
-     125,   126,   127,   128,   129,    39,   131,    -1,   133,   134,
-     135,    -1,    -1,    -1,    -1,    49,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,   152,    -1,     7,
-       8,   156,    -1,   158,    -1,    -1,   161,    -1,   163,    -1,
-     165,    19,    20,    -1,    22,    23,    24,    25,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    59,    -1,    -1,
+      -1,    -1,    -1,    -1,   161,   162,    -1,    -1,   165,    -1,
+     167,   168,    -1,    75,    76,    77,    78,    79,    80,    81,
+      82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
+      92,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   119,   120,   121,
+     122,   123,   124,   125,   126,   127,   128,   129,   130,   131,
+      -1,   133,    -1,   135,   136,   137,    -1,   139,   140,     7,
+       8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    19,    20,    -1,    22,    23,    24,    25,    -1,    -1,
+     162,    -1,    -1,   165,    -1,   167,    -1,   169,    -1,    -1,
       -1,    -1,    40,    41,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    54,   157,   158,    -1,
-      -1,   161,    -1,   163,   164,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    75,    76,    77,
+      -1,    -1,    -1,    -1,    -1,     7,     8,    55,    10,    11,
+      12,    13,    14,    15,    16,    17,    -1,    19,    20,    -1,
+      22,    23,    24,    -1,    -1,    -1,    -1,    75,    76,    77,
       78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
-      88,    89,    90,    91,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,   157,   158,    -1,    -1,   161,    -1,   163,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   117,
-     118,   119,   120,   121,   122,   123,   124,   125,   126,   127,
-     128,   129,    -1,   131,    -1,   133,   134,   135,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,     3,     4,    -1,    -1,
-      -1,    -1,     9,    -1,   152,    -1,    -1,    -1,    -1,    -1,
-     158,    -1,    -1,   161,    -1,   163,    -1,   165,    25,    26,
-      27,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    40,    41,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     7,
-       8,    58,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    75,    76,
+      88,    89,    90,    91,    92,    93,    -1,    -1,    50,    -1,
+       7,     8,    -1,    10,    11,    12,    13,    14,    15,    16,
+      17,    -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,
+      -1,   119,   120,   121,   122,   123,   124,   125,   126,   127,
+     128,   129,   130,   131,    -1,   133,    -1,   135,   136,   137,
+      -1,   139,   140,    50,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   156,    -1,
+       7,     8,   160,    -1,   162,     0,    -1,   165,    -1,   167,
+      -1,   169,    19,    20,    -1,    22,    23,    24,    25,    -1,
+      -1,    -1,    -1,    18,    19,    20,    -1,    22,    23,    24,
+      -1,    -1,    -1,    40,    41,    30,    31,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    55,   161,
+     162,    -1,    -1,   165,    -1,   167,   168,    52,    -1,    -1,
+      -1,    56,    -1,    -1,    -1,    60,    -1,    -1,    75,    76,
       77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
-      87,    88,    89,    90,    91,    -1,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-     117,   118,   119,   120,   121,   122,   123,   124,   125,   126,
-     127,   128,   129,    -1,   131,    -1,   133,   134,   135,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   161,    -1,    -1,    -1,    -1,    -1,
-      -1,    39,    -1,    -1,    -1,   123,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    39,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    39,   160,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,     7,
-       8,    49,    10,    11,    12,    13,    14,    15,    16,    17,
-      -1,    19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,    -1,
-      -1,    49,    -1,    36,    -1,    -1,    -1,    -1,    -1,    -1,
+      87,    88,    89,    90,    91,    92,    93,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   161,   162,    -1,    -1,   165,    -1,
+     167,   168,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,   119,   120,   121,   122,   123,   124,   125,   126,
+     127,   128,   129,   130,   131,    -1,   133,    -1,   135,   136,
+     137,    -1,   139,   140,    -1,     7,     8,    -1,    10,    11,
+      12,    13,    14,    15,    16,    17,    -1,    19,    20,   156,
+      22,    23,    24,    -1,    -1,   162,    -1,    -1,   165,    -1,
+     167,    -1,   169,    -1,     7,     8,    -1,    10,    11,    12,
+      13,    14,    15,    16,    17,    -1,    19,    20,    50,    22,
+      23,    24,     7,     8,    -1,    10,    11,    12,    13,    14,
+      15,    16,    17,    -1,    19,    20,    39,    22,    23,    24,
+      -1,    -1,    -1,    -1,    -1,     7,     8,    50,    10,    11,
+      12,    13,    14,    15,    16,    17,    -1,    19,    20,    -1,
+      22,    23,    24,     7,     8,    50,    10,    11,    12,    13,
+      14,    15,    16,    17,    -1,    19,    20,    39,    22,    23,
+      24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    50,    -1,
+      -1,    -1,    -1,    -1,    -1,     7,     8,    -1,    10,    11,
+      12,    13,    14,    15,    16,    17,    50,    19,    20,    -1,
+      22,    23,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    39,    -1,   161,
+     162,    -1,    -1,   165,    -1,   167,   168,    -1,    50,    -1,
+     125,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,   162,
+      -1,    -1,   165,    -1,   167,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,   161,   162,    -1,    -1,
+     165,    -1,   167,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,
+     162,    -1,    -1,   165,    -1,   167,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,   162,    -1,
+     164,   165,    -1,   167,     7,     8,    -1,    10,    11,    12,
+      13,    14,    15,    16,    17,    -1,    19,    20,    -1,    22,
+      23,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,
+     162,    -1,    -1,   165,    -1,   167,     7,     8,    -1,    10,
+      11,    12,    13,    14,    15,    16,    17,    50,    19,    20,
+      -1,    22,    23,    24,     7,     8,    -1,    10,    11,    12,
+      13,    14,    15,    16,    17,    -1,    19,    20,    39,    22,
+      23,    24,    -1,    -1,    -1,    -1,    -1,     7,     8,    50,
+      10,    11,    12,    13,    14,    15,    16,    17,    -1,    19,
+      20,    -1,    22,    23,    24,     7,     8,    50,    10,    11,
+      12,    13,    14,    15,    16,    17,    -1,    19,    20,    -1,
+      22,    23,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      50,    -1,    -1,    -1,     7,     8,    -1,    10,    11,    12,
+      13,    14,    15,    16,    17,    -1,    19,    20,    50,    22,
+      23,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,   162,
+      -1,   164,   165,    -1,   167,    -1,    -1,    50,     7,     8,
+      -1,    10,    11,    12,    13,    14,    15,    16,    17,    -1,
+      19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,    -1,
+     161,   162,    -1,    -1,   165,    -1,   167,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,   162,
+      -1,    50,   165,    -1,   167,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,   161,   162,    -1,    -1,   165,    -1,   167,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   161,
+     162,    -1,    -1,   165,    -1,   167,     7,     8,    -1,    10,
+      11,    12,    13,    14,    15,    16,    17,    -1,    19,    20,
+      -1,    22,    23,    24,    -1,    -1,    -1,    -1,   161,   162,
+      -1,    -1,   165,    -1,   167,    -1,    -1,    -1,     7,     8,
+      -1,    10,    11,    12,    13,    14,    15,    16,    17,    50,
+      19,    20,    -1,    22,    23,    24,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,   161,   162,    -1,    -1,   165,    -1,   167,     7,
+       8,    50,    10,    11,    12,    13,    14,    15,    16,    17,
+      -1,    19,    20,    -1,    22,    23,    24,     7,     8,    -1,
+      10,    11,    12,    13,    14,    15,    16,    17,    -1,    19,
+      20,    -1,    22,    23,    24,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+     161,   162,    -1,    -1,   165,    -1,   167,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    56,    57,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    69,    70,    71,    72,
-      73,    74,    75,    76,    77,    78,    79,    80,    81,    82,
-      83,    84,    85,    86,    87,    88,    89,    90,    91,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163,    -1,    -1,    -1,   112,
-     113,   114,    -1,    -1,   117,   118,   119,   120,   121,   122,
-     123,   124,   125,   126,   127,   128,   129,   130,   131,   132,
-     133,   134,   135,   136,    -1,    -1,    -1,    -1,    -1,   157,
-     158,    -1,    -1,   161,    -1,   163
+      -1,    -1,   161,   162,    -1,    -1,   165,    -1,   167,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    36,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,   161,   162,    -1,    -1,   165,    -1,   167,
+      -1,    -1,    -1,    -1,    -1,    -1,    57,    58,    -1,    -1,
+      -1,   161,   162,    -1,    -1,   165,    -1,   167,    69,    70,
+      71,    72,    73,    74,    75,    76,    77,    78,    79,    80,
+      81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
+      91,    92,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,   114,   115,   116,    -1,    -1,   119,   120,
+     121,   122,   123,   124,   125,   126,   127,   128,   129,   130,
+     131,   132,   133,   134,   135,   136,   137,   138,   139,   140
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
-       0,    19,    20,    22,    23,    24,    30,    31,    51,    55,
-      59,   174,   177,   178,   179,   180,   212,   213,   214,   216,
-     215,    52,    67,   221,   154,    58,   154,    18,   154,    42,
-      43,    44,    45,    46,    47,    48,    50,   149,   150,   151,
-     181,   182,   183,     0,   214,    46,    48,   184,   231,    42,
-      43,    44,    47,   185,   228,   230,   238,   154,   154,   158,
-     222,    22,   220,     7,     8,    10,    11,    12,    13,    14,
-      15,    16,    17,    49,   157,   158,   161,   163,   174,   178,
-     199,   200,   234,   183,   183,    35,    37,   210,   183,   183,
-      21,    68,   239,   240,    29,   164,   229,   239,    22,    22,
-      22,   223,   152,     4,     4,     4,   163,    10,   164,   200,
-     205,    54,   152,   176,   210,   210,    42,    44,   186,    32,
-      33,   209,    61,    62,    63,    64,    65,    66,   187,   226,
-     226,    68,    38,   177,   243,   155,   160,    39,   200,   201,
-     203,   204,   159,   159,   164,   205,   155,   164,   152,   204,
-     156,   209,   209,    10,   123,   200,   202,   211,    11,    12,
-      13,    14,    15,    16,   172,   173,   200,   206,     4,   202,
-      28,   163,   227,    38,     3,     4,     9,    25,    26,    27,
-      40,    41,    58,    75,    76,    77,    78,    79,    80,    81,
-      82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
-     117,   118,   119,   120,   121,   122,   123,   124,   125,   126,
-     127,   128,   129,   131,   133,   134,   135,   161,   167,   168,
-     169,   207,   233,   234,   235,    36,    56,    57,    69,    70,
-      71,    72,    73,    74,    90,    91,   112,   113,   114,   117,
-     130,   131,   132,   133,   134,   135,   136,   167,   168,   169,
-     241,   247,   248,   249,   250,    22,   189,   155,   153,   200,
-     200,   162,   164,   200,     4,   153,   206,   200,   152,   234,
-      26,    27,     3,     4,     5,     6,     9,    25,    40,    41,
-     158,   161,   163,   165,   207,   234,   176,   178,   235,    60,
-     232,    92,    93,    94,    95,    96,    97,    98,    99,   100,
-     101,   170,    26,    27,    98,    99,   100,   101,   102,   103,
-     104,   105,   106,   107,   108,   109,   110,   111,   171,   152,
-     152,   152,   152,   152,   206,   208,   152,   152,   152,    56,
-      10,   200,   236,   237,    11,    17,    11,   172,   187,   170,
-     171,   200,   200,   236,   200,   200,   244,   236,   236,   236,
-     236,   236,   200,   200,   200,   236,   187,   115,   116,    53,
-     119,   120,   137,   138,   140,   141,   143,   144,   145,   188,
-      39,   201,   191,   160,   162,   162,   153,   191,   176,   176,
-     211,   160,   208,   163,   208,   164,   208,    22,   217,   152,
-      22,   152,   152,   206,   206,   206,   206,   206,   155,   162,
-     206,   206,   206,   235,   155,   235,   235,   235,   202,   200,
-     200,   155,   194,   155,   194,   235,   158,   155,   155,   155,
-     155,   155,   155,   234,   235,   235,    38,   202,   200,   236,
-       4,   137,   138,   139,   142,   146,   147,   190,   218,   219,
-      38,   160,   164,   200,   208,   162,   164,   155,   197,    39,
-     200,   224,   225,   155,   206,   206,   246,   155,   155,   155,
-     155,   206,   155,   155,    38,   236,   155,   155,   235,   235,
-     235,    11,    53,    11,   246,   235,   158,   236,   200,   236,
-     236,   236,   155,   155,   155,   200,   235,   235,   155,   197,
-     197,   200,   162,   164,    34,    53,   195,   198,   189,   155,
-     153,    22,   155,   155,   153,   155,   206,   206,   206,   206,
-     206,   206,   200,    17,    17,   152,   155,   155,   235,     4,
-     235,   155,   235,   155,   155,   155,     4,   235,   235,   152,
-     155,   194,   200,   153,   162,    22,     4,   197,   174,   175,
-      39,   200,   191,   206,   206,   236,   155,   153,   155,   155,
-     153,   153,   153,   235,   235,    17,   200,   245,   235,   235,
-     194,   194,   235,   155,   236,   236,   236,   245,   235,   189,
-     195,   196,   153,   153,   206,   206,   206,   155,   158,   189,
-     189,   153,   155,   160,   235,   153,   194,   175,    53,   193,
-     153,   153,   153,    17,   160,   172,   242,   119,   120,   235,
-     235,   191,    17,   200,   160,   191,     4,   148,   192,   235,
-     233,   160,   172,   189,   189,    38,   189,   189,    22,   155,
-     233,    17,   235,   235,    17,   155,   235,   189,   189,   235,
-      17,    73,   235,    17,   235
+       0,    19,    20,    22,    23,    24,    30,    31,    52,    56,
+      60,   178,   181,   182,   183,   184,   216,   217,   218,   220,
+     219,    53,    68,   225,   158,    59,   158,    18,   158,    42,
+      43,    44,    45,    46,    47,    48,    49,    51,   153,   154,
+     155,   185,   186,   187,     0,   218,    46,    48,   188,   235,
+      42,    43,    44,    47,   189,   232,   234,   242,   158,   158,
+     162,   226,    22,   224,     7,     8,    10,    11,    12,    13,
+      14,    15,    16,    17,    50,   161,   162,   165,   167,   178,
+     182,   203,   204,   238,   187,   187,    35,    37,   214,   187,
+     187,    21,   243,   244,    29,   168,   233,   243,    22,    22,
+      22,   227,   156,     4,     4,     4,   167,    10,   168,   204,
+     209,    55,   156,   180,   214,   214,    42,    44,   190,    32,
+      33,   213,    62,    63,    64,    65,    66,    67,   191,   230,
+     230,   181,   247,   159,   164,    39,   204,   205,   207,   208,
+     163,   163,   168,   209,   159,   168,   156,   208,   160,   213,
+     213,    10,   125,   204,   206,   215,    11,    12,    13,    14,
+      15,    16,   176,   177,   204,   210,     4,   206,    28,   167,
+     231,    36,    57,    58,    69,    70,    71,    72,    73,    74,
+      75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
+      85,    86,    87,    88,    89,    90,    91,    92,    93,   114,
+     115,   116,   119,   120,   121,   122,   123,   124,   125,   126,
+     127,   128,   129,   130,   131,   132,   133,   134,   135,   136,
+     137,   138,   139,   140,   171,   172,   173,   245,   252,   253,
+     254,   255,    22,   193,   159,   157,   204,   204,   166,   168,
+     204,     4,   157,   210,   204,   156,   238,    26,    27,     3,
+       4,     5,     6,     9,    25,    40,    41,    90,    91,    92,
+      93,   119,   133,   135,   136,   137,   139,   140,   162,   165,
+     167,   169,   171,   172,   173,   211,   238,   180,   182,    57,
+      10,   204,   240,   241,    11,    17,    11,   176,   191,    94,
+      95,    96,    97,    98,    99,   100,   101,   102,   103,   174,
+      26,    27,   100,   101,   102,   103,   104,   105,   106,   107,
+     108,   109,   110,   111,   112,   113,   175,   174,   175,   204,
+     204,   240,   204,   204,   248,   240,   240,   240,   240,   240,
+     204,   204,   204,   204,   204,   240,   191,   117,   118,    54,
+     121,   122,   141,   142,   144,   145,   147,   148,   149,   192,
+      39,   205,   195,   164,   166,   166,   157,   195,   180,   180,
+     215,   174,   175,   174,   175,   156,   156,   156,   156,   156,
+     156,   156,   164,   210,   212,   167,   212,   168,   212,    22,
+     156,   156,   156,   221,   156,     3,     4,     9,    25,    26,
+      27,    40,    41,    59,   162,   165,   167,   169,   211,   237,
+     238,   239,   159,   239,   239,   239,   206,   204,   204,   204,
+     204,   159,   198,   159,   198,   239,   162,   159,   159,   159,
+     159,   159,   159,   239,   239,   239,   239,   239,    38,   206,
+     204,   240,     4,   141,   142,   143,   146,   150,   151,   194,
+     222,   223,    38,   156,   156,   156,   156,   210,   210,   210,
+     210,   210,   210,   210,   159,   164,   168,   204,   212,   166,
+     168,   210,   210,   210,   159,   201,    39,   204,   228,   229,
+      61,   236,   164,   212,   167,   212,   168,   212,    22,   240,
+     159,   159,   239,   239,   239,   239,   239,    11,    54,    11,
+     250,   239,   162,   240,   204,   240,   240,   240,   159,   159,
+     251,   159,   159,   159,   204,   239,   239,   159,   201,   201,
+     204,   210,   210,   210,   210,   250,   159,   159,   159,   159,
+     251,   159,   210,   166,   168,   159,   159,    38,    34,    54,
+     199,   202,   193,   159,   157,    22,   164,   168,   212,   166,
+     168,    17,    17,   156,   159,   159,   159,   159,   239,     4,
+     239,   159,   159,   239,   159,   159,   159,     4,     4,   159,
+     204,   239,   239,   156,   159,   198,   204,   157,   159,   159,
+     159,   159,   157,   210,   210,   210,   210,   157,   210,   166,
+     210,   210,   204,    22,     4,   201,   178,   179,    39,   204,
+     195,   159,   166,   168,   239,   239,    17,   204,   249,   239,
+     239,   239,   239,   198,   198,   240,   239,   159,   240,   240,
+     240,     4,   239,   249,   239,   210,   210,   210,   210,   159,
+     157,   159,   159,   251,   157,   157,   157,   193,   199,   200,
+      22,   166,   159,   162,   193,   193,   157,   159,   164,   239,
+     251,   157,   198,   157,   157,   157,   157,   210,   210,   210,
+     157,   179,    54,   197,    17,   164,   176,   246,   121,   122,
+     239,   239,   195,    17,   204,   164,   195,   157,   157,   157,
+       4,   152,   196,   239,   237,   164,   176,   193,   193,    38,
+     193,   193,    22,   159,   237,    17,   239,   239,    17,   159,
+     239,   193,   193,   239,    17,    73,   239,    17,   239
 };
 
 #define yyerrok		(yyerrstatus = 0)
@@ -3486,152 +3598,152 @@
   switch (yyn)
     {
         case 29:
-#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1124 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
     break;
 
   case 30:
-#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1124 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
     break;
 
   case 31:
-#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1125 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
     break;
 
   case 32:
-#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1125 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
     break;
 
   case 33:
-#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1126 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
     break;
 
   case 34:
-#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1126 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
     break;
 
   case 35:
-#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1127 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
     break;
 
   case 36:
-#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1127 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
     break;
 
   case 37:
-#line 1122 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1128 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
     break;
 
   case 38:
-#line 1122 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1128 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
     break;
 
   case 39:
-#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1132 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
     break;
 
   case 40:
-#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1132 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
     break;
 
   case 41:
-#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1133 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
     break;
 
   case 42:
-#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1133 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
     break;
 
   case 43:
-#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1134 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
     break;
 
   case 44:
-#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1134 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
     break;
 
   case 45:
-#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1135 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
     break;
 
   case 46:
-#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1135 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
     break;
 
   case 47:
-#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1136 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
     break;
 
   case 48:
-#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1136 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
     break;
 
   case 49:
-#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1137 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
     break;
 
   case 50:
-#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1137 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
     break;
 
   case 51:
-#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1138 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
     break;
 
   case 52:
-#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1138 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
     break;
 
   case 53:
-#line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1139 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
     break;
 
   case 54:
-#line 1134 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1140 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
     break;
 
   case 65:
-#line 1143 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1149 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.StrVal) = 0; ;}
     break;
 
   case 66:
-#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1151 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
     break;
 
   case 67:
-#line 1146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1152 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.UIntVal)=0; ;}
     break;
 
   case 68:
-#line 1150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1156 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
     CHECK_FOR_ERROR
@@ -3639,7 +3751,7 @@
     break;
 
   case 69:
-#line 1154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1160 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.StrVal) = 0;
     CHECK_FOR_ERROR
@@ -3647,7 +3759,7 @@
     break;
 
   case 73:
-#line 1162 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1168 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.StrVal) = 0;
     CHECK_FOR_ERROR
@@ -3655,7 +3767,7 @@
     break;
 
   case 74:
-#line 1167 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1173 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
     CHECK_FOR_ERROR
@@ -3663,152 +3775,157 @@
     break;
 
   case 75:
-#line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1179 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
     break;
 
   case 76:
-#line 1174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1180 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
     break;
 
   case 77:
-#line 1175 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1181 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
     break;
 
   case 78:
-#line 1176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1182 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
     break;
 
   case 79:
-#line 1177 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1183 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
     break;
 
   case 80:
-#line 1181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
+#line 1184 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::CommonLinkage; ;}
     break;
 
   case 81:
-#line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
+#line 1188 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
     break;
 
   case 82:
-#line 1183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
+#line 1189 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
     break;
 
   case 83:
-#line 1187 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Visibility) = GlobalValue::DefaultVisibility;   ;}
+#line 1190 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
     break;
 
   case 84:
-#line 1188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1194 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.Visibility) = GlobalValue::DefaultVisibility;   ;}
     break;
 
   case 85:
-#line 1189 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Visibility) = GlobalValue::HiddenVisibility;    ;}
+#line 1195 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Visibility) = GlobalValue::DefaultVisibility;   ;}
     break;
 
   case 86:
-#line 1190 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
+#line 1196 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Visibility) = GlobalValue::HiddenVisibility;    ;}
     break;
 
   case 87:
-#line 1194 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
+#line 1197 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
     break;
 
   case 88:
-#line 1195 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
+#line 1201 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
     break;
 
   case 89:
-#line 1196 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
+#line 1202 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
     break;
 
   case 90:
-#line 1200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
+#line 1203 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
     break;
 
   case 91:
-#line 1201 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
+#line 1207 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
     break;
 
   case 92:
-#line 1202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
+#line 1208 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
     break;
 
   case 93:
-#line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
+#line 1209 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
     break;
 
   case 94:
-#line 1204 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
+#line 1210 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
     break;
 
   case 95:
-#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
+#line 1211 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
     break;
 
   case 96:
-#line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
+#line 1215 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
     break;
 
   case 97:
-#line 1210 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
+#line 1216 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
     break;
 
   case 98:
-#line 1213 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.UIntVal) = CallingConv::C; ;}
+#line 1217 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
     break;
 
   case 99:
-#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1220 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.UIntVal) = CallingConv::C; ;}
     break;
 
   case 100:
-#line 1215 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.UIntVal) = CallingConv::Fast; ;}
+#line 1221 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.UIntVal) = CallingConv::C; ;}
     break;
 
   case 101:
-#line 1216 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.UIntVal) = CallingConv::Cold; ;}
+#line 1222 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.UIntVal) = CallingConv::Fast; ;}
     break;
 
   case 102:
-#line 1217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
+#line 1223 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.UIntVal) = CallingConv::Cold; ;}
     break;
 
   case 103:
-#line 1218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
+#line 1224 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
     break;
 
   case 104:
-#line 1219 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1225 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
+    break;
+
+  case 105:
+#line 1226 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
                    if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
                      GEN_ERROR("Calling conv too large");
@@ -3817,130 +3934,130 @@
                  ;}
     break;
 
-  case 105:
-#line 1226 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::ZExt;      ;}
-    break;
-
   case 106:
-#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1233 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::ZExt;      ;}
     break;
 
   case 107:
-#line 1228 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::SExt;      ;}
+#line 1234 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::ZExt;      ;}
     break;
 
   case 108:
-#line 1229 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1235 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::SExt;      ;}
     break;
 
   case 109:
-#line 1230 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::InReg;     ;}
+#line 1236 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::SExt;      ;}
     break;
 
   case 110:
-#line 1231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
+#line 1237 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::InReg;     ;}
     break;
 
   case 111:
-#line 1232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::NoAlias;   ;}
+#line 1238 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
     break;
 
   case 112:
-#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::ByVal;     ;}
+#line 1239 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::NoAlias;   ;}
     break;
 
   case 113:
-#line 1234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::Nest;      ;}
+#line 1240 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::ByVal;     ;}
     break;
 
   case 114:
-#line 1235 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 1241 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { (yyval.ParamAttrs) = ParamAttr::Nest;      ;}
+    break;
+
+  case 115:
+#line 1242 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = 
                           ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val));    ;}
     break;
 
-  case 115:
-#line 1239 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 116:
+#line 1246 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::None; ;}
     break;
 
-  case 116:
-#line 1240 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 117:
+#line 1247 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
                 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
               ;}
     break;
 
-  case 117:
-#line 1245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 118:
+#line 1252 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
     break;
 
-  case 118:
-#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 119:
+#line 1253 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
     break;
 
-  case 119:
-#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 120:
+#line 1254 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::ZExt;     ;}
     break;
 
-  case 120:
-#line 1248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 121:
+#line 1255 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::SExt;     ;}
     break;
 
-  case 121:
-#line 1249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 122:
+#line 1256 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
     break;
 
-  case 122:
-#line 1250 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 123:
+#line 1257 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
     break;
 
-  case 123:
-#line 1253 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 124:
+#line 1260 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamAttrs) = ParamAttr::None; ;}
     break;
 
-  case 124:
-#line 1254 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 125:
+#line 1261 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
                 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
               ;}
     break;
 
-  case 125:
-#line 1259 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 126:
+#line 1266 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.StrVal) = 0; ;}
     break;
 
-  case 126:
-#line 1260 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 127:
+#line 1267 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
                 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
               ;}
     break;
 
-  case 127:
-#line 1267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 128:
+#line 1274 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.UIntVal) = 0; ;}
     break;
 
-  case 128:
-#line 1268 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 129:
+#line 1275 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
   if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
@@ -3949,13 +4066,13 @@
 ;}
     break;
 
-  case 129:
-#line 1274 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 130:
+#line 1281 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.UIntVal) = 0; ;}
     break;
 
-  case 130:
-#line 1275 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 131:
+#line 1282 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
   if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
@@ -3964,8 +4081,8 @@
 ;}
     break;
 
-  case 131:
-#line 1284 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 132:
+#line 1291 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
     if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
@@ -3975,28 +4092,28 @@
 ;}
     break;
 
-  case 132:
-#line 1292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 133:
+#line 1299 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.StrVal) = 0; ;}
     break;
 
-  case 133:
-#line 1293 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 134:
+#line 1300 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
     break;
 
-  case 134:
-#line 1298 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 135:
+#line 1305 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {;}
     break;
 
-  case 135:
-#line 1299 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 136:
+#line 1306 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {;}
     break;
 
-  case 136:
-#line 1300 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 137:
+#line 1307 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
     delete (yyvsp[(1) - (1)].StrVal);
@@ -4004,8 +4121,8 @@
   ;}
     break;
 
-  case 137:
-#line 1305 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 138:
+#line 1312 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
       GEN_ERROR("Alignment must be a power of two");
@@ -4014,24 +4131,24 @@
   ;}
     break;
 
-  case 145:
-#line 1321 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 146:
+#line 1328 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 146:
-#line 1325 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 147:
+#line 1332 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 147:
-#line 1329 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 148:
+#line 1336 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                             // Pointer type?
     if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
       GEN_ERROR("Cannot form a pointer to a basic block");
@@ -4041,8 +4158,8 @@
   ;}
     break;
 
-  case 148:
-#line 1336 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 149:
+#line 1343 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {            // Named types are also simple types...
     const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
     CHECK_FOR_ERROR
@@ -4050,8 +4167,8 @@
   ;}
     break;
 
-  case 149:
-#line 1341 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 150:
+#line 1348 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                   // Type UpReference
     if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
     OpaqueType *OT = OpaqueType::get();        // Use temporary placeholder
@@ -4062,17 +4179,15 @@
   ;}
     break;
 
-  case 150:
-#line 1349 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 151:
+#line 1356 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // Allow but ignore attributes on function types; this permits auto-upgrade.
     // FIXME: remove in LLVM 3.0.
-    const Type* RetTy = *(yyvsp[(1) - (5)].TypeVal);
-    if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
-          isa<StructType>(RetTy) ||
-          isa<OpaqueType>(RetTy)))
-      GEN_ERROR("LLVM Functions cannot return aggregates");
-
+    const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
+    if (!FunctionType::isValidReturnType(RetTy))
+      GEN_ERROR("Invalid result type for LLVM function");
+      
     std::vector<const Type*> Params;
     TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
     for (; I != E; ++I ) {
@@ -4097,8 +4212,8 @@
   ;}
     break;
 
-  case 151:
-#line 1380 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 152:
+#line 1385 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // Allow but ignore attributes on function types; this permits auto-upgrade.
     // FIXME: remove in LLVM 3.0.
@@ -4125,17 +4240,17 @@
   ;}
     break;
 
-  case 152:
-#line 1405 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 153:
+#line 1410 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {          // Sized array type?
-    (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
+    (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (yyvsp[(2) - (5)].UInt64Val))));
     delete (yyvsp[(4) - (5)].TypeVal);
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 153:
-#line 1410 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 154:
+#line 1415 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {          // Vector type?
      const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
      if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
@@ -4148,8 +4263,8 @@
   ;}
     break;
 
-  case 154:
-#line 1420 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 155:
+#line 1425 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                        // Structure type?
     std::vector<const Type*> Elements;
     for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
@@ -4162,16 +4277,16 @@
   ;}
     break;
 
-  case 155:
-#line 1430 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 156:
+#line 1435 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                                  // Empty structure type?
     (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 156:
-#line 1434 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 157:
+#line 1439 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     std::vector<const Type*> Elements;
     for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
@@ -4184,16 +4299,16 @@
   ;}
     break;
 
-  case 157:
-#line 1444 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 158:
+#line 1449 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                         // Empty structure type?
     (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 158:
-#line 1451 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 159:
+#line 1456 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // Allow but ignore attributes on function types; this permits auto-upgrade.
     // FIXME: remove in LLVM 3.0.
@@ -4202,8 +4317,8 @@
   ;}
     break;
 
-  case 159:
-#line 1460 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 160:
+#line 1465 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
@@ -4213,15 +4328,15 @@
   ;}
     break;
 
-  case 160:
-#line 1467 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 161:
+#line 1472 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
   ;}
     break;
 
-  case 161:
-#line 1472 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 162:
+#line 1477 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
     (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
@@ -4229,16 +4344,16 @@
   ;}
     break;
 
-  case 162:
-#line 1477 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 163:
+#line 1482 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 164:
-#line 1485 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 165:
+#line 1490 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
     TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
@@ -4248,8 +4363,8 @@
   ;}
     break;
 
-  case 165:
-#line 1492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 166:
+#line 1497 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
     TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
@@ -4259,16 +4374,16 @@
   ;}
     break;
 
-  case 166:
-#line 1499 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 167:
+#line 1504 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 167:
-#line 1507 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 168:
+#line 1512 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TypeList) = new std::list<PATypeHolder>();
     (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal)); 
@@ -4277,8 +4392,8 @@
   ;}
     break;
 
-  case 168:
-#line 1513 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 169:
+#line 1518 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal)); 
     delete (yyvsp[(3) - (3)].TypeVal);
@@ -4286,8 +4401,8 @@
   ;}
     break;
 
-  case 169:
-#line 1525 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 170:
+#line 1530 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { // Nonempty unsized arr
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
@@ -4296,13 +4411,13 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
     const Type *ETy = ATy->getElementType();
-    int NumElements = ATy->getNumElements();
+    uint64_t NumElements = ATy->getNumElements();
 
     // Verify that we have the correct size...
-    if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
+    if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (4)].ConstVector)->size())
       GEN_ERROR("Type mismatch: constant sized array initialized with " +
                      utostr((yyvsp[(3) - (4)].ConstVector)->size()) +  " arguments, but has size of " + 
-                     itostr(NumElements) + "");
+                     utostr(NumElements) + "");
 
     // Verify all elements are correct type!
     for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
@@ -4318,8 +4433,8 @@
   ;}
     break;
 
-  case 170:
-#line 1553 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 171:
+#line 1558 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
@@ -4328,18 +4443,18 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
 
-    int NumElements = ATy->getNumElements();
-    if (NumElements != -1 && NumElements != 0) 
+    uint64_t NumElements = ATy->getNumElements();
+    if (NumElements != uint64_t(-1) && NumElements != 0) 
       GEN_ERROR("Type mismatch: constant sized array initialized with 0"
-                     " arguments, but has size of " + itostr(NumElements) +"");
+                     " arguments, but has size of " + utostr(NumElements) +"");
     (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
     delete (yyvsp[(1) - (3)].TypeVal);
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 171:
-#line 1569 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 172:
+#line 1574 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
@@ -4348,15 +4463,15 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
 
-    int NumElements = ATy->getNumElements();
+    uint64_t NumElements = ATy->getNumElements();
     const Type *ETy = ATy->getElementType();
-    if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
+    if (NumElements != uint64_t(-1) && NumElements != (yyvsp[(3) - (3)].StrVal)->length())
       GEN_ERROR("Can't build string constant of size " + 
-                     itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
-                     " when array has size " + itostr(NumElements) + "");
+                     utostr((yyvsp[(3) - (3)].StrVal)->length()) +
+                     " when array has size " + utostr(NumElements) + "");
     std::vector<Constant*> Vals;
     if (ETy == Type::Int8Ty) {
-      for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
+      for (uint64_t i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
         Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
     } else {
       delete (yyvsp[(3) - (3)].StrVal);
@@ -4369,8 +4484,8 @@
   ;}
     break;
 
-  case 172:
-#line 1596 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 173:
+#line 1601 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { // Nonempty unsized arr
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
@@ -4379,13 +4494,13 @@
       GEN_ERROR("Cannot make packed constant with type: '" + 
                      (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
     const Type *ETy = PTy->getElementType();
-    int NumElements = PTy->getNumElements();
+    unsigned NumElements = PTy->getNumElements();
 
     // Verify that we have the correct size...
-    if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
+    if (NumElements != unsigned(-1) && NumElements != (unsigned)(yyvsp[(3) - (4)].ConstVector)->size())
       GEN_ERROR("Type mismatch: constant sized packed initialized with " +
                      utostr((yyvsp[(3) - (4)].ConstVector)->size()) +  " arguments, but has size of " + 
-                     itostr(NumElements) + "");
+                     utostr(NumElements) + "");
 
     // Verify all elements are correct type!
     for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
@@ -4401,8 +4516,8 @@
   ;}
     break;
 
-  case 173:
-#line 1624 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 174:
+#line 1629 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
     if (STy == 0)
@@ -4431,8 +4546,8 @@
   ;}
     break;
 
-  case 174:
-#line 1650 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 175:
+#line 1655 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
@@ -4455,8 +4570,8 @@
   ;}
     break;
 
-  case 175:
-#line 1670 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 176:
+#line 1675 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
     if (STy == 0)
@@ -4485,8 +4600,8 @@
   ;}
     break;
 
-  case 176:
-#line 1696 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 177:
+#line 1701 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
@@ -4509,8 +4624,8 @@
   ;}
     break;
 
-  case 177:
-#line 1716 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 178:
+#line 1721 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
@@ -4525,8 +4640,8 @@
   ;}
     break;
 
-  case 178:
-#line 1728 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 179:
+#line 1733 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
@@ -4536,8 +4651,8 @@
   ;}
     break;
 
-  case 179:
-#line 1735 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 180:
+#line 1740 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
@@ -4606,8 +4721,8 @@
   ;}
     break;
 
-  case 180:
-#line 1801 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 181:
+#line 1806 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
@@ -4620,8 +4735,8 @@
   ;}
     break;
 
-  case 181:
-#line 1811 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 182:
+#line 1816 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
@@ -4634,8 +4749,8 @@
   ;}
     break;
 
-  case 182:
-#line 1821 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 183:
+#line 1826 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {      // integral constants
     if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
       GEN_ERROR("Constant value doesn't fit in type");
@@ -4644,8 +4759,8 @@
   ;}
     break;
 
-  case 183:
-#line 1827 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 184:
+#line 1832 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {      // arbitrary precision integer constants
     uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
     if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
@@ -4658,8 +4773,8 @@
   ;}
     break;
 
-  case 184:
-#line 1837 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 185:
+#line 1842 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {      // integral constants
     if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
       GEN_ERROR("Constant value doesn't fit in type");
@@ -4668,8 +4783,8 @@
   ;}
     break;
 
-  case 185:
-#line 1843 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 186:
+#line 1848 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {      // arbitrary precision integer constants
     uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
     if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
@@ -4682,26 +4797,28 @@
   ;}
     break;
 
-  case 186:
-#line 1853 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 187:
+#line 1858 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                      // Boolean constants
-    assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
+      GEN_ERROR("Constant true must have type i1");
     (yyval.ConstVal) = ConstantInt::getTrue();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 187:
-#line 1858 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 188:
+#line 1864 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                     // Boolean constants
-    assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() != 1)
+      GEN_ERROR("Constant false must have type i1");
     (yyval.ConstVal) = ConstantInt::getFalse();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 188:
-#line 1863 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 189:
+#line 1870 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                   // Floating point constants
     if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
       GEN_ERROR("Floating point constant invalid for type");
@@ -4715,8 +4832,8 @@
   ;}
     break;
 
-  case 189:
-#line 1876 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 190:
+#line 1883 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
@@ -4731,15 +4848,14 @@
   ;}
     break;
 
-  case 190:
-#line 1888 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 191:
+#line 1895 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
       GEN_ERROR("GetElementPtr requires a pointer operand");
 
     const Type *IdxTy =
-      GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
-                                        true);
+      GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end());
     if (!IdxTy)
       GEN_ERROR("Index list invalid for constant getelementptr");
 
@@ -4757,8 +4873,8 @@
   ;}
     break;
 
-  case 191:
-#line 1910 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 192:
+#line 1916 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
       GEN_ERROR("Select condition must be of boolean type");
@@ -4769,8 +4885,8 @@
   ;}
     break;
 
-  case 192:
-#line 1918 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 193:
+#line 1924 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
       GEN_ERROR("Binary operator types must match");
@@ -4779,8 +4895,8 @@
   ;}
     break;
 
-  case 193:
-#line 1924 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 194:
+#line 1930 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
       GEN_ERROR("Logical operator types must match");
@@ -4794,8 +4910,8 @@
   ;}
     break;
 
-  case 194:
-#line 1935 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 195:
+#line 1941 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
       GEN_ERROR("icmp operand types must match");
@@ -4803,8 +4919,8 @@
   ;}
     break;
 
-  case 195:
-#line 1940 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 196:
+#line 1946 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
       GEN_ERROR("fcmp operand types must match");
@@ -4812,8 +4928,26 @@
   ;}
     break;
 
-  case 196:
-#line 1945 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 197:
+#line 1951 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
+      GEN_ERROR("vicmp operand types must match");
+    (yyval.ConstVal) = ConstantExpr::getVICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
+  ;}
+    break;
+
+  case 198:
+#line 1956 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
+      GEN_ERROR("vfcmp operand types must match");
+    (yyval.ConstVal) = ConstantExpr::getVFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
+  ;}
+    break;
+
+  case 199:
+#line 1961 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
       GEN_ERROR("Invalid extractelement operands");
@@ -4822,8 +4956,8 @@
   ;}
     break;
 
-  case 197:
-#line 1951 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 200:
+#line 1967 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
       GEN_ERROR("Invalid insertelement operands");
@@ -4832,8 +4966,8 @@
   ;}
     break;
 
-  case 198:
-#line 1957 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 201:
+#line 1973 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
       GEN_ERROR("Invalid shufflevector operands");
@@ -4842,16 +4976,40 @@
   ;}
     break;
 
-  case 199:
-#line 1966 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 202:
+#line 1979 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if (!isa<StructType>((yyvsp[(3) - (5)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (5)].ConstVal)->getType()))
+      GEN_ERROR("ExtractValue requires an aggregate operand");
+
+    (yyval.ConstVal) = ConstantExpr::getExtractValue((yyvsp[(3) - (5)].ConstVal), &(*(yyvsp[(4) - (5)].ConstantList))[0], (yyvsp[(4) - (5)].ConstantList)->size());
+    delete (yyvsp[(4) - (5)].ConstantList);
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 203:
+#line 1987 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if (!isa<StructType>((yyvsp[(3) - (7)].ConstVal)->getType()) && !isa<ArrayType>((yyvsp[(3) - (7)].ConstVal)->getType()))
+      GEN_ERROR("InsertValue requires an aggregate operand");
+
+    (yyval.ConstVal) = ConstantExpr::getInsertValue((yyvsp[(3) - (7)].ConstVal), (yyvsp[(5) - (7)].ConstVal), &(*(yyvsp[(6) - (7)].ConstantList))[0], (yyvsp[(6) - (7)].ConstantList)->size());
+    delete (yyvsp[(6) - (7)].ConstantList);
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 204:
+#line 1998 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 200:
-#line 1970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 205:
+#line 2002 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ConstVector) = new std::vector<Constant*>();
     (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
@@ -4859,28 +5017,28 @@
   ;}
     break;
 
-  case 201:
-#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 206:
+#line 2010 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.BoolVal) = false; ;}
     break;
 
-  case 202:
-#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 207:
+#line 2010 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.BoolVal) = true; ;}
     break;
 
-  case 203:
-#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 208:
+#line 2013 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.BoolVal) = true; ;}
     break;
 
-  case 204:
-#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 209:
+#line 2013 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.BoolVal) = false; ;}
     break;
 
-  case 205:
-#line 1984 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 210:
+#line 2016 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
     Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
@@ -4895,8 +5053,8 @@
    ;}
     break;
 
-  case 206:
-#line 1996 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 211:
+#line 2028 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     Constant *Val = (yyvsp[(3) - (6)].ConstVal);
     const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
@@ -4911,8 +5069,8 @@
    ;}
     break;
 
-  case 207:
-#line 2017 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 212:
+#line 2049 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
     CurModule.ModuleDone();
@@ -4920,8 +5078,8 @@
   ;}
     break;
 
-  case 208:
-#line 2022 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 213:
+#line 2054 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
     CurModule.ModuleDone();
@@ -4929,40 +5087,40 @@
   ;}
     break;
 
-  case 211:
-#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 216:
+#line 2067 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { CurFun.isDeclare = false; ;}
     break;
 
-  case 212:
-#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 217:
+#line 2067 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurFun.FunctionDone();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 213:
-#line 2039 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 218:
+#line 2071 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { CurFun.isDeclare = true; ;}
     break;
 
-  case 214:
-#line 2039 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 219:
+#line 2071 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 215:
-#line 2042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 220:
+#line 2074 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 216:
-#line 2045 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 221:
+#line 2077 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
@@ -4989,8 +5147,8 @@
   ;}
     break;
 
-  case 217:
-#line 2069 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 222:
+#line 2101 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
 
@@ -5004,8 +5162,8 @@
   ;}
     break;
 
-  case 218:
-#line 2081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 223:
+#line 2113 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { 
     /* "Externally Visible" Linkage */
     if ((yyvsp[(5) - (6)].ConstVal) == 0) 
@@ -5016,15 +5174,15 @@
   ;}
     break;
 
-  case 219:
-#line 2088 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 224:
+#line 2120 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurGV = 0;
   ;}
     break;
 
-  case 220:
-#line 2092 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 225:
+#line 2124 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(6) - (7)].ConstVal) == 0) 
       GEN_ERROR("Global value initializer is not a constant");
@@ -5033,15 +5191,15 @@
   ;}
     break;
 
-  case 221:
-#line 2097 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 226:
+#line 2129 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurGV = 0;
   ;}
     break;
 
-  case 222:
-#line 2101 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 227:
+#line 2133 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
@@ -5051,16 +5209,16 @@
   ;}
     break;
 
-  case 223:
-#line 2107 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 228:
+#line 2139 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurGV = 0;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 224:
-#line 2111 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 229:
+#line 2143 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     std::string Name;
     if ((yyvsp[(1) - (5)].StrVal)) {
@@ -5103,22 +5261,22 @@
   ;}
     break;
 
-  case 225:
-#line 2151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 230:
+#line 2183 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { 
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 226:
-#line 2154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 231:
+#line 2186 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 227:
-#line 2160 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 232:
+#line 2192 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
   if (AsmSoFar.empty())
@@ -5130,24 +5288,24 @@
 ;}
     break;
 
-  case 228:
-#line 2170 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 233:
+#line 2202 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
     delete (yyvsp[(3) - (3)].StrVal);
   ;}
     break;
 
-  case 229:
-#line 2174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 234:
+#line 2206 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
     delete (yyvsp[(3) - (3)].StrVal);
   ;}
     break;
 
-  case 231:
-#line 2181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 236:
+#line 2213 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
           CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
           delete (yyvsp[(3) - (3)].StrVal);
@@ -5155,8 +5313,8 @@
         ;}
     break;
 
-  case 232:
-#line 2186 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 237:
+#line 2218 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
           CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
           delete (yyvsp[(1) - (1)].StrVal);
@@ -5164,20 +5322,20 @@
         ;}
     break;
 
-  case 233:
-#line 2191 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 238:
+#line 2223 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
           CHECK_FOR_ERROR
         ;}
     break;
 
-  case 234:
-#line 2200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 239:
+#line 2232 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
-    if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
-      GEN_ERROR("void typed arguments are invalid");
+    if (!(*(yyvsp[(3) - (5)].TypeVal))->isFirstClassType())
+      GEN_ERROR("Argument types must be first-class");
     ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
     (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
     (yyvsp[(1) - (5)].ArgList)->push_back(E);
@@ -5185,13 +5343,13 @@
   ;}
     break;
 
-  case 235:
-#line 2210 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 240:
+#line 2242 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
-    if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
-      GEN_ERROR("void typed arguments are invalid");
+    if (!(*(yyvsp[(1) - (3)].TypeVal))->isFirstClassType())
+      GEN_ERROR("Argument types must be first-class");
     ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
     (yyval.ArgList) = new ArgListType;
     (yyval.ArgList)->push_back(E);
@@ -5199,16 +5357,16 @@
   ;}
     break;
 
-  case 236:
-#line 2221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 241:
+#line 2253 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 237:
-#line 2225 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 242:
+#line 2257 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
     struct ArgListEntry E;
@@ -5220,8 +5378,8 @@
   ;}
     break;
 
-  case 238:
-#line 2234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 243:
+#line 2266 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ArgList) = new ArgListType;
     struct ArgListEntry E;
@@ -5233,16 +5391,16 @@
   ;}
     break;
 
-  case 239:
-#line 2243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 244:
+#line 2275 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ArgList) = 0;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 240:
-#line 2249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 245:
+#line 2281 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
   delete (yyvsp[(3) - (10)].StrVal);  // Free strdup'd memory!
@@ -5252,6 +5410,9 @@
   if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
     GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
 
+  if (!FunctionType::isValidReturnType(*(yyvsp[(2) - (10)].TypeVal)))
+    GEN_ERROR("Invalid result type for LLVM function");
+    
   std::vector<const Type*> ParamTypeList;
   SmallVector<ParamAttrsWithIndex, 8> Attrs;
   if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None)
@@ -5369,8 +5530,8 @@
 ;}
     break;
 
-  case 243:
-#line 2376 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 248:
+#line 2411 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   (yyval.FunctionVal) = CurFun.CurrentFunction;
 
@@ -5381,16 +5542,16 @@
 ;}
     break;
 
-  case 246:
-#line 2387 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 251:
+#line 2422 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
   CHECK_FOR_ERROR
 ;}
     break;
 
-  case 247:
-#line 2392 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 252:
+#line 2427 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
     CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
@@ -5400,100 +5561,97 @@
   ;}
     break;
 
-  case 248:
-#line 2404 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 253:
+#line 2439 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.BoolVal) = false;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 249:
-#line 2408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 254:
+#line 2443 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.BoolVal) = true;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 250:
-#line 2413 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 255:
+#line 2448 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {    // A reference to a direct constant
     (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 251:
-#line 2417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 256:
+#line 2452 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 252:
-#line 2421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 257:
+#line 2456 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                     // Perhaps it's an FP constant?
     (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 253:
-#line 2425 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 258:
+#line 2460 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 254:
-#line 2429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 259:
+#line 2464 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 255:
-#line 2433 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 260:
+#line 2468 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::createNull();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 256:
-#line 2437 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 261:
+#line 2472 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::createUndef();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 257:
-#line 2441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 262:
+#line 2476 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {     // A vector zero constant.
     (yyval.ValIDVal) = ValID::createZeroInit();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 258:
-#line 2445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 263:
+#line 2480 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { // Nonempty unsized packed vector
     const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
-    int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); 
+    unsigned NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); 
+
+    if (!ETy->isInteger() && !ETy->isFloatingPoint())
+      GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
     
     VectorType* pt = VectorType::get(ETy, NumElements);
-    PATypeHolder* PTy = new PATypeHolder(
-                                         HandleUpRefs(
-                                            VectorType::get(
-                                                ETy, 
-                                                NumElements)
-                                            )
-                                         );
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
     
     // Verify all elements are correct type!
     for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
@@ -5509,16 +5667,120 @@
   ;}
     break;
 
-  case 259:
-#line 2470 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 264:
+#line 2502 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    { // Nonempty unsized arr
+    const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
+    uint64_t NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); 
+
+    if (!ETy->isFirstClassType())
+      GEN_ERROR("Invalid array element type: " + ETy->getDescription());
+
+    ArrayType *ATy = ArrayType::get(ETy, NumElements);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
+
+    // Verify all elements are correct type!
+    for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
+      if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
+        GEN_ERROR("Element #" + utostr(i) + " is not of type '" + 
+                       ETy->getDescription() +"' as required!\nIt is of type '"+
+                       (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
+    }
+
+    (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, *(yyvsp[(2) - (3)].ConstVector)));
+    delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 265:
+#line 2524 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    // Use undef instead of an array because it's inconvenient to determine
+    // the element type at this point, there being no elements to examine.
+    (yyval.ValIDVal) = ValID::createUndef();
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 266:
+#line 2530 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    uint64_t NumElements = (yyvsp[(2) - (2)].StrVal)->length();
+    const Type *ETy = Type::Int8Ty;
+
+    ArrayType *ATy = ArrayType::get(ETy, NumElements);
+
+    std::vector<Constant*> Vals;
+    for (unsigned i = 0; i < (yyvsp[(2) - (2)].StrVal)->length(); ++i)
+      Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(2) - (2)].StrVal))[i]));
+    delete (yyvsp[(2) - (2)].StrVal);
+    (yyval.ValIDVal) = ValID::create(ConstantArray::get(ATy, Vals));
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 267:
+#line 2543 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    std::vector<const Type*> Elements((yyvsp[(2) - (3)].ConstVector)->size());
+    for (unsigned i = 0, e = (yyvsp[(2) - (3)].ConstVector)->size(); i != e; ++i)
+      Elements[i] = (*(yyvsp[(2) - (3)].ConstVector))[i]->getType();
+
+    const StructType *STy = StructType::get(Elements);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
+
+    (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(2) - (3)].ConstVector)));
+    delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 268:
+#line 2555 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    const StructType *STy = StructType::get(std::vector<const Type*>());
+    (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 269:
+#line 2560 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    std::vector<const Type*> Elements((yyvsp[(3) - (5)].ConstVector)->size());
+    for (unsigned i = 0, e = (yyvsp[(3) - (5)].ConstVector)->size(); i != e; ++i)
+      Elements[i] = (*(yyvsp[(3) - (5)].ConstVector))[i]->getType();
+
+    const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
+
+    (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, *(yyvsp[(3) - (5)].ConstVector)));
+    delete PTy; delete (yyvsp[(3) - (5)].ConstVector);
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 270:
+#line 2572 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    const StructType *STy = StructType::get(std::vector<const Type*>(),
+                                            /*isPacked=*/true);
+    (yyval.ValIDVal) = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 271:
+#line 2578 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 260:
-#line 2474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 272:
+#line 2582 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
     delete (yyvsp[(3) - (5)].StrVal);
@@ -5527,24 +5789,24 @@
   ;}
     break;
 
-  case 261:
-#line 2484 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 273:
+#line 2592 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {  // Is it an integer reference...?
     (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 262:
-#line 2488 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 274:
+#line 2596 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 263:
-#line 2492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 275:
+#line 2600 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                   // Is it a named reference...?
     (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
     delete (yyvsp[(1) - (1)].StrVal);
@@ -5552,8 +5814,8 @@
   ;}
     break;
 
-  case 264:
-#line 2497 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 276:
+#line 2605 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                   // Is it a named reference...?
     (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
     delete (yyvsp[(1) - (1)].StrVal);
@@ -5561,8 +5823,8 @@
   ;}
     break;
 
-  case 267:
-#line 2510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 279:
+#line 2618 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
@@ -5572,8 +5834,8 @@
   ;}
     break;
 
-  case 268:
-#line 2519 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 280:
+#line 2627 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValueList) = new std::vector<Value *>();
     (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal)); 
@@ -5581,32 +5843,32 @@
   ;}
     break;
 
-  case 269:
-#line 2524 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 281:
+#line 2632 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal)); 
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 270:
-#line 2529 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 282:
+#line 2637 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 271:
-#line 2533 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 283:
+#line 2641 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { // Do not allow functions with 0 basic blocks   
     (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 272:
-#line 2542 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 284:
+#line 2650 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
     CHECK_FOR_ERROR
@@ -5617,8 +5879,8 @@
   ;}
     break;
 
-  case 273:
-#line 2551 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 285:
+#line 2659 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
       if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
@@ -5630,42 +5892,26 @@
   ;}
     break;
 
-  case 274:
-#line 2560 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 286:
+#line 2668 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {          // Empty space between instruction lists
-    (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
+    (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 275:
-#line 2564 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    {   // Only the unwind to block
-    (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal((yyvsp[(3) - (3)].ValIDVal)));
-    CHECK_FOR_ERROR
-  ;}
-    break;
-
-  case 276:
-#line 2568 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 287:
+#line 2672 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {             // Labelled (named) basic block
-    (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)), 0);
+    (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
     delete (yyvsp[(1) - (1)].StrVal);
     CHECK_FOR_ERROR
-  ;}
-    break;
 
-  case 277:
-#line 2573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
-    {
-    (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (4)].StrVal)), getBBVal((yyvsp[(4) - (4)].ValIDVal)));
-    delete (yyvsp[(1) - (4)].StrVal);
-    CHECK_FOR_ERROR
   ;}
     break;
 
-  case 278:
-#line 2580 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 288:
+#line 2680 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { // Return with a result...
     ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
     assert(!VL.empty() && "Invalid ret operands!");
@@ -5675,16 +5921,16 @@
   ;}
     break;
 
-  case 279:
-#line 2587 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 289:
+#line 2687 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                                    // Return with no result...
     (yyval.TermInstVal) = ReturnInst::Create();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 280:
-#line 2591 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 290:
+#line 2691 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {                           // Unconditional Branch...
     BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
     CHECK_FOR_ERROR
@@ -5692,10 +5938,11 @@
   ;}
     break;
 
-  case 281:
-#line 2596 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 291:
+#line 2696 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {  
-    assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() != 1)
+      GEN_ERROR("Branch condition must have type i1");
     BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
     CHECK_FOR_ERROR
     BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
@@ -5706,8 +5953,8 @@
   ;}
     break;
 
-  case 282:
-#line 2606 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 292:
+#line 2707 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
     CHECK_FOR_ERROR
@@ -5729,8 +5976,8 @@
   ;}
     break;
 
-  case 283:
-#line 2625 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 293:
+#line 2726 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
     CHECK_FOR_ERROR
@@ -5742,8 +5989,8 @@
   ;}
     break;
 
-  case 284:
-#line 2635 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 294:
+#line 2736 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
 
     // Handle the short syntax
@@ -5760,6 +6007,10 @@
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
       }
+      
+      if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (14)].TypeVal)))
+        GEN_ERROR("Invalid result type for LLVM function");
+
       Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
       PFTy = PointerType::getUnqual(Ty);
     }
@@ -5817,7 +6068,8 @@
       PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
 
     // Create the InvokeInst
-    InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
+    InvokeInst *II = InvokeInst::Create(V, Normal, Except,
+                                        Args.begin(), Args.end());
     II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
     II->setParamAttrs(PAL);
     (yyval.TermInstVal) = II;
@@ -5826,24 +6078,24 @@
   ;}
     break;
 
-  case 285:
-#line 2715 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 295:
+#line 2821 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TermInstVal) = new UnwindInst();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 286:
-#line 2719 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 296:
+#line 2825 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.TermInstVal) = new UnreachableInst();
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 287:
-#line 2726 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 297:
+#line 2832 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
     Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
@@ -5857,8 +6109,8 @@
   ;}
     break;
 
-  case 288:
-#line 2737 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 298:
+#line 2843 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
     Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
@@ -5873,8 +6125,8 @@
   ;}
     break;
 
-  case 289:
-#line 2750 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 299:
+#line 2856 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // Is this definition named?? if so, assign the name...
     setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
@@ -5885,8 +6137,8 @@
   ;}
     break;
 
-  case 290:
-#line 2760 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 300:
+#line 2866 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {    // Used for PHI nodes
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
@@ -5900,8 +6152,8 @@
   ;}
     break;
 
-  case 291:
-#line 2771 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 301:
+#line 2877 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
     Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
@@ -5912,8 +6164,8 @@
   ;}
     break;
 
-  case 292:
-#line 2781 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 302:
+#line 2887 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
     if (!UpRefs.empty())
@@ -5927,8 +6179,8 @@
   ;}
     break;
 
-  case 293:
-#line 2792 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 303:
+#line 2898 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
     // Labels are only valid in ASMs
@@ -5939,8 +6191,8 @@
   ;}
     break;
 
-  case 294:
-#line 2800 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 304:
+#line 2906 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
     if (!UpRefs.empty())
@@ -5953,8 +6205,8 @@
   ;}
     break;
 
-  case 295:
-#line 2810 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 305:
+#line 2916 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
     (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
@@ -5964,18 +6216,18 @@
   ;}
     break;
 
-  case 296:
-#line 2817 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 306:
+#line 2923 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ParamList) = new ParamList(); ;}
     break;
 
-  case 297:
-#line 2820 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 307:
+#line 2926 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     { (yyval.ValueList) = new std::vector<Value*>(); ;}
     break;
 
-  case 298:
-#line 2821 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 308:
+#line 2927 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
     (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
@@ -5983,24 +6235,45 @@
   ;}
     break;
 
-  case 299:
-#line 2828 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 309:
+#line 2935 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    (yyval.ConstantList) = new std::vector<unsigned>();
+    if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
+      GEN_ERROR("Index " + utostr((yyvsp[(2) - (2)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
+    (yyval.ConstantList)->push_back((yyvsp[(2) - (2)].UInt64Val));
+  ;}
+    break;
+
+  case 310:
+#line 2941 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    (yyval.ConstantList) = (yyvsp[(1) - (3)].ConstantList);
+    if ((unsigned)(yyvsp[(3) - (3)].UInt64Val) != (yyvsp[(3) - (3)].UInt64Val))
+      GEN_ERROR("Index " + utostr((yyvsp[(3) - (3)].UInt64Val)) + " is not valid for insertvalue or extractvalue.");
+    (yyval.ConstantList)->push_back((yyvsp[(3) - (3)].UInt64Val));
+    CHECK_FOR_ERROR
+  ;}
+    break;
+
+  case 311:
+#line 2950 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.BoolVal) = true;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 300:
-#line 2832 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 312:
+#line 2954 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.BoolVal) = false;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 301:
-#line 2837 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 313:
+#line 2959 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
@@ -6012,15 +6285,15 @@
     CHECK_FOR_ERROR
     Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
     CHECK_FOR_ERROR
-    (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
+    (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
     if ((yyval.InstVal) == 0)
       GEN_ERROR("binary operator returned null");
     delete (yyvsp[(2) - (5)].TypeVal);
   ;}
     break;
 
-  case 302:
-#line 2853 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 314:
+#line 2975 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
@@ -6033,15 +6306,15 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
     CHECK_FOR_ERROR
-    (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
+    (yyval.InstVal) = BinaryOperator::Create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
     if ((yyval.InstVal) == 0)
       GEN_ERROR("binary operator returned null");
     delete (yyvsp[(2) - (5)].TypeVal);
   ;}
     break;
 
-  case 303:
-#line 2870 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 315:
+#line 2992 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
@@ -6051,15 +6324,15 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
     CHECK_FOR_ERROR
-    (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
+    (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
     if ((yyval.InstVal) == 0)
       GEN_ERROR("icmp operator returned null");
     delete (yyvsp[(3) - (6)].TypeVal);
   ;}
     break;
 
-  case 304:
-#line 2884 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 316:
+#line 3006 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
@@ -6069,15 +6342,51 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
     CHECK_FOR_ERROR
-    (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
+    (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
     if ((yyval.InstVal) == 0)
       GEN_ERROR("fcmp operator returned null");
     delete (yyvsp[(3) - (6)].TypeVal);
   ;}
     break;
 
-  case 305:
-#line 2898 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 317:
+#line 3020 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
+    if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
+      GEN_ERROR("Scalar types not supported by vicmp instruction");
+    Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
+    CHECK_FOR_ERROR
+    (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
+    if ((yyval.InstVal) == 0)
+      GEN_ERROR("icmp operator returned null");
+    delete (yyvsp[(3) - (6)].TypeVal);
+  ;}
+    break;
+
+  case 318:
+#line 3034 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
+    if (!isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
+      GEN_ERROR("Scalar types not supported by vfcmp instruction");
+    Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
+    CHECK_FOR_ERROR
+    (yyval.InstVal) = CmpInst::Create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
+    if ((yyval.InstVal) == 0)
+      GEN_ERROR("fcmp operator returned null");
+    delete (yyvsp[(3) - (6)].TypeVal);
+  ;}
+    break;
+
+  case 319:
+#line 3048 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
@@ -6087,13 +6396,13 @@
       GEN_ERROR("invalid cast opcode for cast from '" +
                 Val->getType()->getDescription() + "' to '" +
                 DestTy->getDescription() + "'"); 
-    (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
+    (yyval.InstVal) = CastInst::Create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
     delete (yyvsp[(4) - (4)].TypeVal);
   ;}
     break;
 
-  case 306:
-#line 2910 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 320:
+#line 3060 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
       GEN_ERROR("select condition must be boolean");
@@ -6104,8 +6413,8 @@
   ;}
     break;
 
-  case 307:
-#line 2918 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 321:
+#line 3068 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
@@ -6115,8 +6424,8 @@
   ;}
     break;
 
-  case 308:
-#line 2925 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 322:
+#line 3075 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
       GEN_ERROR("Invalid extractelement operands");
@@ -6125,8 +6434,8 @@
   ;}
     break;
 
-  case 309:
-#line 2931 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 323:
+#line 3081 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
       GEN_ERROR("Invalid insertelement operands");
@@ -6135,8 +6444,8 @@
   ;}
     break;
 
-  case 310:
-#line 2937 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 324:
+#line 3087 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
       GEN_ERROR("Invalid shufflevector operands");
@@ -6145,8 +6454,8 @@
   ;}
     break;
 
-  case 311:
-#line 2943 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 325:
+#line 3093 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
     if (!Ty->isFirstClassType())
@@ -6164,8 +6473,8 @@
   ;}
     break;
 
-  case 312:
-#line 2959 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 326:
+#line 3109 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
 
     // Handle the short syntax
@@ -6182,6 +6491,10 @@
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
       }
+
+      if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (8)].TypeVal)))
+        GEN_ERROR("Invalid result type for LLVM function");
+
       Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
       PFTy = PointerType::getUnqual(Ty);
     }
@@ -6253,32 +6566,32 @@
   ;}
     break;
 
-  case 313:
-#line 3044 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 327:
+#line 3198 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 314:
-#line 3049 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 328:
+#line 3203 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.BoolVal) = true;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 315:
-#line 3053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 329:
+#line 3207 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     (yyval.BoolVal) = false;
     CHECK_FOR_ERROR
   ;}
     break;
 
-  case 316:
-#line 3060 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 330:
+#line 3214 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
@@ -6288,11 +6601,13 @@
   ;}
     break;
 
-  case 317:
-#line 3067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 331:
+#line 3221 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
+    if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
+      GEN_ERROR("Malloc array size is not a 32-bit integer!");
     Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
     CHECK_FOR_ERROR
     (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
@@ -6300,8 +6615,8 @@
   ;}
     break;
 
-  case 318:
-#line 3075 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 332:
+#line 3231 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
@@ -6311,11 +6626,13 @@
   ;}
     break;
 
-  case 319:
-#line 3082 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 333:
+#line 3238 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
+    if ((yyvsp[(4) - (6)].PrimType) != Type::Int32Ty)
+      GEN_ERROR("Alloca array size is not a 32-bit integer!");
     Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
     CHECK_FOR_ERROR
     (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
@@ -6323,8 +6640,8 @@
   ;}
     break;
 
-  case 320:
-#line 3090 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 334:
+#line 3248 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
       GEN_ERROR("Trying to free nonpointer type " + 
@@ -6334,8 +6651,8 @@
   ;}
     break;
 
-  case 321:
-#line 3098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 335:
+#line 3256 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
@@ -6352,8 +6669,8 @@
   ;}
     break;
 
-  case 322:
-#line 3112 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 336:
+#line 3270 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
@@ -6373,8 +6690,8 @@
   ;}
     break;
 
-  case 323:
-#line 3129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 337:
+#line 3287 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
   Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal));
   if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val)))
@@ -6385,15 +6702,15 @@
   ;}
     break;
 
-  case 324:
-#line 3137 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+  case 338:
+#line 3295 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
     {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
     if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
       GEN_ERROR("getelementptr insn requires pointer operand");
 
-    if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end(), true))
+    if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()))
       GEN_ERROR("Invalid getelementptr indices for type '" +
                      (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
     Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
@@ -6404,9 +6721,49 @@
   ;}
     break;
 
+  case 339:
+#line 3310 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
+    if (!isa<StructType>((yyvsp[(2) - (4)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (4)].TypeVal)->get()))
+      GEN_ERROR("extractvalue insn requires an aggregate operand");
+
+    if (!ExtractValueInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end()))
+      GEN_ERROR("Invalid extractvalue indices for type '" +
+                     (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
+    Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
+    CHECK_FOR_ERROR
+    (yyval.InstVal) = ExtractValueInst::Create(tmpVal, (yyvsp[(4) - (4)].ConstantList)->begin(), (yyvsp[(4) - (4)].ConstantList)->end());
+    delete (yyvsp[(2) - (4)].TypeVal); 
+    delete (yyvsp[(4) - (4)].ConstantList);
+  ;}
+    break;
+
+  case 340:
+#line 3325 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
+    {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (7)].TypeVal))->getDescription());
+    if (!isa<StructType>((yyvsp[(2) - (7)].TypeVal)->get()) && !isa<ArrayType>((yyvsp[(2) - (7)].TypeVal)->get()))
+      GEN_ERROR("extractvalue insn requires an aggregate operand");
+
+    if (ExtractValueInst::getIndexedType(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end()) != (yyvsp[(5) - (7)].TypeVal)->get())
+      GEN_ERROR("Invalid insertvalue indices for type '" +
+                     (*(yyvsp[(2) - (7)].TypeVal))->getDescription()+ "'");
+    Value* aggVal = getVal(*(yyvsp[(2) - (7)].TypeVal), (yyvsp[(3) - (7)].ValIDVal));
+    Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
+    CHECK_FOR_ERROR
+    (yyval.InstVal) = InsertValueInst::Create(aggVal, tmpVal, (yyvsp[(7) - (7)].ConstantList)->begin(), (yyvsp[(7) - (7)].ConstantList)->end());
+    delete (yyvsp[(2) - (7)].TypeVal); 
+    delete (yyvsp[(5) - (7)].TypeVal);
+    delete (yyvsp[(7) - (7)].ConstantList);
+  ;}
+    break;
+
 
 /* Line 1267 of yacc.c.  */
-#line 6410 "llvmAsmParser.tab.c"
+#line 6767 "llvmAsmParser.tab.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -6620,7 +6977,7 @@
 }
 
 
-#line 3154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 3344 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
 
 
 // common code from the two 'RunVMAsmParser' functions

Modified: llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.h.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.h.cvs?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.h.cvs (original)
+++ llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.h.cvs Sun Jul  6 15:45:41 2008
@@ -85,26 +85,26 @@
      DLLIMPORT = 301,
      DLLEXPORT = 302,
      EXTERN_WEAK = 303,
-     OPAQUE = 304,
-     EXTERNAL = 305,
-     TARGET = 306,
-     TRIPLE = 307,
-     ALIGN = 308,
-     ADDRSPACE = 309,
-     DEPLIBS = 310,
-     CALL = 311,
-     TAIL = 312,
-     ASM_TOK = 313,
-     MODULE = 314,
-     SIDEEFFECT = 315,
-     CC_TOK = 316,
-     CCC_TOK = 317,
-     FASTCC_TOK = 318,
-     COLDCC_TOK = 319,
-     X86_STDCALLCC_TOK = 320,
-     X86_FASTCALLCC_TOK = 321,
-     DATALAYOUT = 322,
-     UNWINDS = 323,
+     COMMON = 304,
+     OPAQUE = 305,
+     EXTERNAL = 306,
+     TARGET = 307,
+     TRIPLE = 308,
+     ALIGN = 309,
+     ADDRSPACE = 310,
+     DEPLIBS = 311,
+     CALL = 312,
+     TAIL = 313,
+     ASM_TOK = 314,
+     MODULE = 315,
+     SIDEEFFECT = 316,
+     CC_TOK = 317,
+     CCC_TOK = 318,
+     FASTCC_TOK = 319,
+     COLDCC_TOK = 320,
+     X86_STDCALLCC_TOK = 321,
+     X86_FASTCALLCC_TOK = 322,
+     DATALAYOUT = 323,
      RET = 324,
      BR = 325,
      SWITCH = 326,
@@ -128,66 +128,70 @@
      ASHR = 344,
      ICMP = 345,
      FCMP = 346,
-     EQ = 347,
-     NE = 348,
-     SLT = 349,
-     SGT = 350,
-     SLE = 351,
-     SGE = 352,
-     ULT = 353,
-     UGT = 354,
-     ULE = 355,
-     UGE = 356,
-     OEQ = 357,
-     ONE = 358,
-     OLT = 359,
-     OGT = 360,
-     OLE = 361,
-     OGE = 362,
-     ORD = 363,
-     UNO = 364,
-     UEQ = 365,
-     UNE = 366,
-     MALLOC = 367,
-     ALLOCA = 368,
-     FREE = 369,
-     LOAD = 370,
-     STORE = 371,
-     GETELEMENTPTR = 372,
-     TRUNC = 373,
-     ZEXT = 374,
-     SEXT = 375,
-     FPTRUNC = 376,
-     FPEXT = 377,
-     BITCAST = 378,
-     UITOFP = 379,
-     SITOFP = 380,
-     FPTOUI = 381,
-     FPTOSI = 382,
-     INTTOPTR = 383,
-     PTRTOINT = 384,
-     PHI_TOK = 385,
-     SELECT = 386,
-     VAARG = 387,
-     EXTRACTELEMENT = 388,
-     INSERTELEMENT = 389,
-     SHUFFLEVECTOR = 390,
-     GETRESULT = 391,
-     SIGNEXT = 392,
-     ZEROEXT = 393,
-     NORETURN = 394,
-     INREG = 395,
-     SRET = 396,
-     NOUNWIND = 397,
-     NOALIAS = 398,
-     BYVAL = 399,
-     NEST = 400,
-     READNONE = 401,
-     READONLY = 402,
-     GC = 403,
-     DEFAULT = 404,
-     HIDDEN = 405,
-     PROTECTED = 406
+     VICMP = 347,
+     VFCMP = 348,
+     EQ = 349,
+     NE = 350,
+     SLT = 351,
+     SGT = 352,
+     SLE = 353,
+     SGE = 354,
+     ULT = 355,
+     UGT = 356,
+     ULE = 357,
+     UGE = 358,
+     OEQ = 359,
+     ONE = 360,
+     OLT = 361,
+     OGT = 362,
+     OLE = 363,
+     OGE = 364,
+     ORD = 365,
+     UNO = 366,
+     UEQ = 367,
+     UNE = 368,
+     MALLOC = 369,
+     ALLOCA = 370,
+     FREE = 371,
+     LOAD = 372,
+     STORE = 373,
+     GETELEMENTPTR = 374,
+     TRUNC = 375,
+     ZEXT = 376,
+     SEXT = 377,
+     FPTRUNC = 378,
+     FPEXT = 379,
+     BITCAST = 380,
+     UITOFP = 381,
+     SITOFP = 382,
+     FPTOUI = 383,
+     FPTOSI = 384,
+     INTTOPTR = 385,
+     PTRTOINT = 386,
+     PHI_TOK = 387,
+     SELECT = 388,
+     VAARG = 389,
+     EXTRACTELEMENT = 390,
+     INSERTELEMENT = 391,
+     SHUFFLEVECTOR = 392,
+     GETRESULT = 393,
+     EXTRACTVALUE = 394,
+     INSERTVALUE = 395,
+     SIGNEXT = 396,
+     ZEROEXT = 397,
+     NORETURN = 398,
+     INREG = 399,
+     SRET = 400,
+     NOUNWIND = 401,
+     NOALIAS = 402,
+     BYVAL = 403,
+     NEST = 404,
+     READNONE = 405,
+     READONLY = 406,
+     GC = 407,
+     DEFAULT = 408,
+     HIDDEN = 409,
+     PROTECTED = 410
    };
 #endif
 /* Tokens.  */
@@ -237,26 +241,26 @@
 #define DLLIMPORT 301
 #define DLLEXPORT 302
 #define EXTERN_WEAK 303
-#define OPAQUE 304
-#define EXTERNAL 305
-#define TARGET 306
-#define TRIPLE 307
-#define ALIGN 308
-#define ADDRSPACE 309
-#define DEPLIBS 310
-#define CALL 311
-#define TAIL 312
-#define ASM_TOK 313
-#define MODULE 314
-#define SIDEEFFECT 315
-#define CC_TOK 316
-#define CCC_TOK 317
-#define FASTCC_TOK 318
-#define COLDCC_TOK 319
-#define X86_STDCALLCC_TOK 320
-#define X86_FASTCALLCC_TOK 321
-#define DATALAYOUT 322
-#define UNWINDS 323
+#define COMMON 304
+#define OPAQUE 305
+#define EXTERNAL 306
+#define TARGET 307
+#define TRIPLE 308
+#define ALIGN 309
+#define ADDRSPACE 310
+#define DEPLIBS 311
+#define CALL 312
+#define TAIL 313
+#define ASM_TOK 314
+#define MODULE 315
+#define SIDEEFFECT 316
+#define CC_TOK 317
+#define CCC_TOK 318
+#define FASTCC_TOK 319
+#define COLDCC_TOK 320
+#define X86_STDCALLCC_TOK 321
+#define X86_FASTCALLCC_TOK 322
+#define DATALAYOUT 323
 #define RET 324
 #define BR 325
 #define SWITCH 326
@@ -280,73 +284,77 @@
 #define ASHR 344
 #define ICMP 345
 #define FCMP 346
-#define EQ 347
-#define NE 348
-#define SLT 349
-#define SGT 350
-#define SLE 351
-#define SGE 352
-#define ULT 353
-#define UGT 354
-#define ULE 355
-#define UGE 356
-#define OEQ 357
-#define ONE 358
-#define OLT 359
-#define OGT 360
-#define OLE 361
-#define OGE 362
-#define ORD 363
-#define UNO 364
-#define UEQ 365
-#define UNE 366
-#define MALLOC 367
-#define ALLOCA 368
-#define FREE 369
-#define LOAD 370
-#define STORE 371
-#define GETELEMENTPTR 372
-#define TRUNC 373
-#define ZEXT 374
-#define SEXT 375
-#define FPTRUNC 376
-#define FPEXT 377
-#define BITCAST 378
-#define UITOFP 379
-#define SITOFP 380
-#define FPTOUI 381
-#define FPTOSI 382
-#define INTTOPTR 383
-#define PTRTOINT 384
-#define PHI_TOK 385
-#define SELECT 386
-#define VAARG 387
-#define EXTRACTELEMENT 388
-#define INSERTELEMENT 389
-#define SHUFFLEVECTOR 390
-#define GETRESULT 391
-#define SIGNEXT 392
-#define ZEROEXT 393
-#define NORETURN 394
-#define INREG 395
-#define SRET 396
-#define NOUNWIND 397
-#define NOALIAS 398
-#define BYVAL 399
-#define NEST 400
-#define READNONE 401
-#define READONLY 402
-#define GC 403
-#define DEFAULT 404
-#define HIDDEN 405
-#define PROTECTED 406
+#define VICMP 347
+#define VFCMP 348
+#define EQ 349
+#define NE 350
+#define SLT 351
+#define SGT 352
+#define SLE 353
+#define SGE 354
+#define ULT 355
+#define UGT 356
+#define ULE 357
+#define UGE 358
+#define OEQ 359
+#define ONE 360
+#define OLT 361
+#define OGT 362
+#define OLE 363
+#define OGE 364
+#define ORD 365
+#define UNO 366
+#define UEQ 367
+#define UNE 368
+#define MALLOC 369
+#define ALLOCA 370
+#define FREE 371
+#define LOAD 372
+#define STORE 373
+#define GETELEMENTPTR 374
+#define TRUNC 375
+#define ZEXT 376
+#define SEXT 377
+#define FPTRUNC 378
+#define FPEXT 379
+#define BITCAST 380
+#define UITOFP 381
+#define SITOFP 382
+#define FPTOUI 383
+#define FPTOSI 384
+#define INTTOPTR 385
+#define PTRTOINT 386
+#define PHI_TOK 387
+#define SELECT 388
+#define VAARG 389
+#define EXTRACTELEMENT 390
+#define INSERTELEMENT 391
+#define SHUFFLEVECTOR 392
+#define GETRESULT 393
+#define EXTRACTVALUE 394
+#define INSERTVALUE 395
+#define SIGNEXT 396
+#define ZEROEXT 397
+#define NORETURN 398
+#define INREG 399
+#define SRET 400
+#define NOUNWIND 401
+#define NOALIAS 402
+#define BYVAL 403
+#define NEST 404
+#define READNONE 405
+#define READONLY 406
+#define GC 407
+#define DEFAULT 408
+#define HIDDEN 409
+#define PROTECTED 410
 
 
 
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 950 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 953 "/Volumes/Data/Code/work/llvm2/lib/AsmParser/llvmAsmParser.y"
 {
   llvm::Module                           *ModuleVal;
   llvm::Function                         *FunctionVal;
@@ -360,6 +368,7 @@
   llvm::PATypeHolder                     *TypeVal;
   llvm::Value                            *ValueVal;
   std::vector<llvm::Value*>              *ValueList;
+  std::vector<unsigned>                  *ConstantList;
   llvm::ArgListType                      *ArgList;
   llvm::TypeWithAttrs                     TypeWithAttrs;
   llvm::TypeWithAttrsList                *TypeWithAttrsList;
@@ -394,7 +403,7 @@
   llvm::FCmpInst::Predicate         FPredicate;
 }
 /* Line 1529 of yacc.c.  */
-#line 398 "llvmAsmParser.tab.h"
+#line 407 "llvmAsmParser.tab.h"
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1

Modified: llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y Sun Jul  6 15:45:41 2008
@@ -475,7 +475,7 @@
   if (TriggerError) return 0;
 
   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
-    GenerateError("Invalid use of a composite type");
+    GenerateError("Invalid use of a non-first-class type");
     return 0;
   }
 
@@ -517,7 +517,7 @@
 
 /// defineBBVal - This is a definition of a new basic block with the specified
 /// identifier which must be the same as CurFun.NextValNum, if its numeric.
-static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) {
+static BasicBlock *defineBBVal(const ValID &ID) {
   assert(inFunctionScope() && "Can't get basic block at global scope!");
 
   BasicBlock *BB = 0;
@@ -559,7 +559,6 @@
   }
 
   ID.destroy();
-  BB->setUnwindDest(unwindDest);
   return BB;
 }
 
@@ -732,6 +731,10 @@
     GenerateError("Cannot declare global vars of function type");
     return 0;
   }
+  if (Ty == Type::LabelTy) {
+    GenerateError("Cannot declare global vars of label type");
+    return 0;
+  }
 
   const PointerType *PTy = PointerType::get(Ty, AddressSpace);
 
@@ -960,6 +963,7 @@
   llvm::PATypeHolder                     *TypeVal;
   llvm::Value                            *ValueVal;
   std::vector<llvm::Value*>              *ValueList;
+  std::vector<unsigned>                  *ConstantList;
   llvm::ArgListType                      *ArgList;
   llvm::TypeWithAttrs                     TypeWithAttrs;
   llvm::TypeWithAttrsList                *TypeWithAttrsList;
@@ -1005,6 +1009,7 @@
 %type <PHIList>       PHIList
 %type <ParamList>     ParamList      // For call param lists & GEP indices
 %type <ValueList>     IndexList         // For GEP indices
+%type <ConstantList>  ConstantIndexList // For insertvalue/extractvalue indices
 %type <TypeList>      TypeListI 
 %type <TypeWithAttrsList> ArgTypeList ArgTypeListI
 %type <TypeWithAttrs> ArgType
@@ -1059,11 +1064,11 @@
 %token ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
 %token DECLARE DEFINE GLOBAL CONSTANT SECTION ALIAS VOLATILE THREAD_LOCAL
 %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING
-%token DLLIMPORT DLLEXPORT EXTERN_WEAK
+%token DLLIMPORT DLLEXPORT EXTERN_WEAK COMMON
 %token OPAQUE EXTERNAL TARGET TRIPLE ALIGN ADDRSPACE
 %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
 %token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
-%token DATALAYOUT UNWINDS
+%token DATALAYOUT
 %type <UIntVal> OptCallingConv
 %type <ParamAttrs> OptParamAttrs ParamAttr 
 %type <ParamAttrs> OptFuncAttrs  FuncAttr
@@ -1076,7 +1081,7 @@
 %token <BinaryOpVal> ADD SUB MUL UDIV SDIV FDIV UREM SREM FREM AND OR XOR
 %token <BinaryOpVal> SHL LSHR ASHR
 
-%token <OtherOpVal> ICMP FCMP
+%token <OtherOpVal> ICMP FCMP VICMP VFCMP
 %type  <IPredicate> IPredicates
 %type  <FPredicate> FPredicates
 %token  EQ NE SLT SGT SLE SGE ULT UGT ULE UGE 
@@ -1094,6 +1099,7 @@
 %token <OtherOpVal> PHI_TOK SELECT VAARG
 %token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
 %token <OtherOpVal> GETRESULT
+%token <OtherOpVal> EXTRACTVALUE INSERTVALUE
 
 // Function Attributes
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
@@ -1175,6 +1181,7 @@
   | LINKONCE    { $$ = GlobalValue::LinkOnceLinkage; }
   | APPENDING   { $$ = GlobalValue::AppendingLinkage; }
   | DLLEXPORT   { $$ = GlobalValue::DLLExportLinkage; } 
+  | COMMON      { $$ = GlobalValue::CommonLinkage; }
   ;
 
 GVExternalLinkage
@@ -1349,12 +1356,10 @@
   | Types '(' ArgTypeListI ')' OptFuncAttrs {
     // Allow but ignore attributes on function types; this permits auto-upgrade.
     // FIXME: remove in LLVM 3.0.
-    const Type* RetTy = *$1;
-    if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
-          isa<StructType>(RetTy) ||
-          isa<OpaqueType>(RetTy)))
-      GEN_ERROR("LLVM Functions cannot return aggregates");
-
+    const Type *RetTy = *$1;
+    if (!FunctionType::isValidReturnType(RetTy))
+      GEN_ERROR("Invalid result type for LLVM function");
+      
     std::vector<const Type*> Params;
     TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
     for (; I != E; ++I ) {
@@ -1403,7 +1408,7 @@
   }
 
   | '[' EUINT64VAL 'x' Types ']' {          // Sized array type?
-    $$ = new PATypeHolder(HandleUpRefs(ArrayType::get(*$4, (unsigned)$2)));
+    $$ = new PATypeHolder(HandleUpRefs(ArrayType::get(*$4, $2)));
     delete $4;
     CHECK_FOR_ERROR
   }
@@ -1530,13 +1535,13 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'");
     const Type *ETy = ATy->getElementType();
-    int NumElements = ATy->getNumElements();
+    uint64_t NumElements = ATy->getNumElements();
 
     // Verify that we have the correct size...
-    if (NumElements != -1 && NumElements != (int)$3->size())
+    if (NumElements != uint64_t(-1) && NumElements != $3->size())
       GEN_ERROR("Type mismatch: constant sized array initialized with " +
                      utostr($3->size()) +  " arguments, but has size of " + 
-                     itostr(NumElements) + "");
+                     utostr(NumElements) + "");
 
     // Verify all elements are correct type!
     for (unsigned i = 0; i < $3->size(); i++) {
@@ -1558,10 +1563,10 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'");
 
-    int NumElements = ATy->getNumElements();
-    if (NumElements != -1 && NumElements != 0) 
+    uint64_t NumElements = ATy->getNumElements();
+    if (NumElements != uint64_t(-1) && NumElements != 0) 
       GEN_ERROR("Type mismatch: constant sized array initialized with 0"
-                     " arguments, but has size of " + itostr(NumElements) +"");
+                     " arguments, but has size of " + utostr(NumElements) +"");
     $$ = ConstantArray::get(ATy, std::vector<Constant*>());
     delete $1;
     CHECK_FOR_ERROR
@@ -1574,15 +1579,15 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'");
 
-    int NumElements = ATy->getNumElements();
+    uint64_t NumElements = ATy->getNumElements();
     const Type *ETy = ATy->getElementType();
-    if (NumElements != -1 && NumElements != int($3->length()))
+    if (NumElements != uint64_t(-1) && NumElements != $3->length())
       GEN_ERROR("Can't build string constant of size " + 
-                     itostr((int)($3->length())) +
-                     " when array has size " + itostr(NumElements) + "");
+                     utostr($3->length()) +
+                     " when array has size " + utostr(NumElements) + "");
     std::vector<Constant*> Vals;
     if (ETy == Type::Int8Ty) {
-      for (unsigned i = 0; i < $3->length(); ++i)
+      for (uint64_t i = 0; i < $3->length(); ++i)
         Vals.push_back(ConstantInt::get(ETy, (*$3)[i]));
     } else {
       delete $3;
@@ -1601,13 +1606,13 @@
       GEN_ERROR("Cannot make packed constant with type: '" + 
                      (*$1)->getDescription() + "'");
     const Type *ETy = PTy->getElementType();
-    int NumElements = PTy->getNumElements();
+    unsigned NumElements = PTy->getNumElements();
 
     // Verify that we have the correct size...
-    if (NumElements != -1 && NumElements != (int)$3->size())
+    if (NumElements != unsigned(-1) && NumElements != (unsigned)$3->size())
       GEN_ERROR("Type mismatch: constant sized packed initialized with " +
                      utostr($3->size()) +  " arguments, but has size of " + 
-                     itostr(NumElements) + "");
+                     utostr(NumElements) + "");
 
     // Verify all elements are correct type!
     for (unsigned i = 0; i < $3->size(); i++) {
@@ -1851,12 +1856,14 @@
     CHECK_FOR_ERROR
   }
   | INTTYPE TRUETOK {                      // Boolean constants
-    assert(cast<IntegerType>($1)->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>($1)->getBitWidth() != 1)
+      GEN_ERROR("Constant true must have type i1");
     $$ = ConstantInt::getTrue();
     CHECK_FOR_ERROR
   }
   | INTTYPE FALSETOK {                     // Boolean constants
-    assert(cast<IntegerType>($1)->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>($1)->getBitWidth() != 1)
+      GEN_ERROR("Constant false must have type i1");
     $$ = ConstantInt::getFalse();
     CHECK_FOR_ERROR
   }
@@ -1890,8 +1897,7 @@
       GEN_ERROR("GetElementPtr requires a pointer operand");
 
     const Type *IdxTy =
-      GetElementPtrInst::getIndexedType($3->getType(), $4->begin(), $4->end(),
-                                        true);
+      GetElementPtrInst::getIndexedType($3->getType(), $4->begin(), $4->end());
     if (!IdxTy)
       GEN_ERROR("Index list invalid for constant getelementptr");
 
@@ -1942,6 +1948,16 @@
       GEN_ERROR("fcmp operand types must match");
     $$ = ConstantExpr::getFCmp($2, $4, $6);
   }
+  | VICMP IPredicates '(' ConstVal ',' ConstVal ')' {
+    if ($4->getType() != $6->getType())
+      GEN_ERROR("vicmp operand types must match");
+    $$ = ConstantExpr::getVICmp($2, $4, $6);
+  }
+  | VFCMP FPredicates '(' ConstVal ',' ConstVal ')' {
+    if ($4->getType() != $6->getType())
+      GEN_ERROR("vfcmp operand types must match");
+    $$ = ConstantExpr::getVFCmp($2, $4, $6);
+  }
   | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
     if (!ExtractElementInst::isValidOperands($3, $5))
       GEN_ERROR("Invalid extractelement operands");
@@ -1959,6 +1975,22 @@
       GEN_ERROR("Invalid shufflevector operands");
     $$ = ConstantExpr::getShuffleVector($3, $5, $7);
     CHECK_FOR_ERROR
+  }
+  | EXTRACTVALUE '(' ConstVal ConstantIndexList ')' {
+    if (!isa<StructType>($3->getType()) && !isa<ArrayType>($3->getType()))
+      GEN_ERROR("ExtractValue requires an aggregate operand");
+
+    $$ = ConstantExpr::getExtractValue($3, &(*$4)[0], $4->size());
+    delete $4;
+    CHECK_FOR_ERROR
+  }
+  | INSERTVALUE '(' ConstVal ',' ConstVal ConstantIndexList ')' {
+    if (!isa<StructType>($3->getType()) && !isa<ArrayType>($3->getType()))
+      GEN_ERROR("InsertValue requires an aggregate operand");
+
+    $$ = ConstantExpr::getInsertValue($3, $5, &(*$6)[0], $6->size());
+    delete $6;
+    CHECK_FOR_ERROR
   };
 
 
@@ -2200,8 +2232,8 @@
 ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
-    if (*$3 == Type::VoidTy)
-      GEN_ERROR("void typed arguments are invalid");
+    if (!(*$3)->isFirstClassType())
+      GEN_ERROR("Argument types must be first-class");
     ArgListEntry E; E.Attrs = $4; E.Ty = $3; E.Name = $5;
     $$ = $1;
     $1->push_back(E);
@@ -2210,8 +2242,8 @@
   | Types OptParamAttrs OptLocalName {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
-    if (*$1 == Type::VoidTy)
-      GEN_ERROR("void typed arguments are invalid");
+    if (!(*$1)->isFirstClassType())
+      GEN_ERROR("Argument types must be first-class");
     ArgListEntry E; E.Attrs = $2; E.Ty = $1; E.Name = $3;
     $$ = new ArgListType;
     $$->push_back(E);
@@ -2255,6 +2287,9 @@
   if (!CurFun.isDeclare && CurModule.TypeIsUnresolved($2))
     GEN_ERROR("Reference to abstract result: "+ $2->get()->getDescription());
 
+  if (!FunctionType::isValidReturnType(*$2))
+    GEN_ERROR("Invalid result type for LLVM function");
+    
   std::vector<const Type*> ParamTypeList;
   SmallVector<ParamAttrsWithIndex, 8> Attrs;
   if ($7 != ParamAttr::None)
@@ -2444,16 +2479,13 @@
   }
   | '<' ConstVector '>' { // Nonempty unsized packed vector
     const Type *ETy = (*$2)[0]->getType();
-    int NumElements = $2->size(); 
+    unsigned NumElements = $2->size(); 
+
+    if (!ETy->isInteger() && !ETy->isFloatingPoint())
+      GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
     
     VectorType* pt = VectorType::get(ETy, NumElements);
-    PATypeHolder* PTy = new PATypeHolder(
-                                         HandleUpRefs(
-                                            VectorType::get(
-                                                ETy, 
-                                                NumElements)
-                                            )
-                                         );
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
     
     // Verify all elements are correct type!
     for (unsigned i = 0; i < $2->size(); i++) {
@@ -2467,6 +2499,82 @@
     delete PTy; delete $2;
     CHECK_FOR_ERROR
   }
+  | '[' ConstVector ']' { // Nonempty unsized arr
+    const Type *ETy = (*$2)[0]->getType();
+    uint64_t NumElements = $2->size(); 
+
+    if (!ETy->isFirstClassType())
+      GEN_ERROR("Invalid array element type: " + ETy->getDescription());
+
+    ArrayType *ATy = ArrayType::get(ETy, NumElements);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
+
+    // Verify all elements are correct type!
+    for (unsigned i = 0; i < $2->size(); i++) {
+      if (ETy != (*$2)[i]->getType())
+        GEN_ERROR("Element #" + utostr(i) + " is not of type '" + 
+                       ETy->getDescription() +"' as required!\nIt is of type '"+
+                       (*$2)[i]->getType()->getDescription() + "'.");
+    }
+
+    $$ = ValID::create(ConstantArray::get(ATy, *$2));
+    delete PTy; delete $2;
+    CHECK_FOR_ERROR
+  }
+  | '[' ']' {
+    // Use undef instead of an array because it's inconvenient to determine
+    // the element type at this point, there being no elements to examine.
+    $$ = ValID::createUndef();
+    CHECK_FOR_ERROR
+  }
+  | 'c' STRINGCONSTANT {
+    uint64_t NumElements = $2->length();
+    const Type *ETy = Type::Int8Ty;
+
+    ArrayType *ATy = ArrayType::get(ETy, NumElements);
+
+    std::vector<Constant*> Vals;
+    for (unsigned i = 0; i < $2->length(); ++i)
+      Vals.push_back(ConstantInt::get(ETy, (*$2)[i]));
+    delete $2;
+    $$ = ValID::create(ConstantArray::get(ATy, Vals));
+    CHECK_FOR_ERROR
+  }
+  | '{' ConstVector '}' {
+    std::vector<const Type*> Elements($2->size());
+    for (unsigned i = 0, e = $2->size(); i != e; ++i)
+      Elements[i] = (*$2)[i]->getType();
+
+    const StructType *STy = StructType::get(Elements);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
+
+    $$ = ValID::create(ConstantStruct::get(STy, *$2));
+    delete PTy; delete $2;
+    CHECK_FOR_ERROR
+  }
+  | '{' '}' {
+    const StructType *STy = StructType::get(std::vector<const Type*>());
+    $$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
+    CHECK_FOR_ERROR
+  }
+  | '<' '{' ConstVector '}' '>' {
+    std::vector<const Type*> Elements($3->size());
+    for (unsigned i = 0, e = $3->size(); i != e; ++i)
+      Elements[i] = (*$3)[i]->getType();
+
+    const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
+
+    $$ = ValID::create(ConstantStruct::get(STy, *$3));
+    delete PTy; delete $3;
+    CHECK_FOR_ERROR
+  }
+  | '<' '{' '}' '>' {
+    const StructType *STy = StructType::get(std::vector<const Type*>(),
+                                            /*isPacked=*/true);
+    $$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
+    CHECK_FOR_ERROR
+  }
   | ConstExpr {
     $$ = ValID::create($1);
     CHECK_FOR_ERROR
@@ -2558,7 +2666,7 @@
     CHECK_FOR_ERROR
   }
   | /* empty */ {          // Empty space between instruction lists
-    $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
+    $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
     CHECK_FOR_ERROR
   }
   | UNWINDS TO ValueRef {  // Only the unwind to block
@@ -2570,21 +2678,17 @@
     $$->setDoesNotThrow();
     CHECK_FOR_ERROR
   }
-  | NOUNWIND UNWINDS TO ValueRef {  // Only the nounwind and unwind to block
+  | NOUNWIND UNWINDS TO ValueRef {  // The nounwind and unwind to block
     $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal($4));
     $$->setDoesNotThrow();
     CHECK_FOR_ERROR
   }
  
   | LABELSTR {             // Labelled (named) basic block
-    $$ = defineBBVal(ValID::createLocalName(*$1), 0);
-    delete $1;
-    CHECK_FOR_ERROR
-  }
-  | LABELSTR UNWINDS TO ValueRef {
-    $$ = defineBBVal(ValID::createLocalName(*$1), getBBVal($4));
+    $$ = defineBBVal(ValID::createLocalName(*$1));
     delete $1;
     CHECK_FOR_ERROR
+
   };
   | LABELSTR NOUNWIND {
     $$ = defineBBVal(ValID::createLocalName(*$1), 0);
@@ -2617,7 +2721,8 @@
     $$ = BranchInst::Create(tmpBB);
   }                                               // Conditional Branch...
   | BR INTTYPE ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {  
-    assert(cast<IntegerType>($2)->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>($2)->getBitWidth() != 1)
+      GEN_ERROR("Branch condition must have type i1");
     BasicBlock* tmpBBA = getBBVal($6);
     CHECK_FOR_ERROR
     BasicBlock* tmpBBB = getBBVal($9);
@@ -2671,6 +2776,10 @@
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
       }
+      
+      if (!FunctionType::isValidReturnType(*$3))
+        GEN_ERROR("Invalid result type for LLVM function");
+
       Ty = FunctionType::get($3->get(), ParamTypes, false);
       PFTy = PointerType::getUnqual(Ty);
     }
@@ -2728,7 +2837,8 @@
       PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
 
     // Create the InvokeInst
-    InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
+    InvokeInst *II = InvokeInst::Create(V, Normal, Except,
+                                        Args.begin(), Args.end());
     II->setCallingConv($2);
     II->setParamAttrs(PAL);
     $$ = II;
@@ -2848,6 +2958,22 @@
   }
   ;
 
+ConstantIndexList       // Used for insertvalue and extractvalue instructions
+  : ',' EUINT64VAL {
+    $$ = new std::vector<unsigned>();
+    if ((unsigned)$2 != $2)
+      GEN_ERROR("Index " + utostr($2) + " is not valid for insertvalue or extractvalue.");
+    $$->push_back($2);
+  }
+  | ConstantIndexList ',' EUINT64VAL {
+    $$ = $1;
+    if ((unsigned)$3 != $3)
+      GEN_ERROR("Index " + utostr($3) + " is not valid for insertvalue or extractvalue.");
+    $$->push_back($3);
+    CHECK_FOR_ERROR
+  }
+  ;
+
 OptTailCall : TAIL CALL {
     $$ = true;
     CHECK_FOR_ERROR
@@ -2868,7 +2994,7 @@
     CHECK_FOR_ERROR
     Value* val2 = getVal(*$2, $5);
     CHECK_FOR_ERROR
-    $$ = BinaryOperator::create($1, val1, val2);
+    $$ = BinaryOperator::Create($1, val1, val2);
     if ($$ == 0)
       GEN_ERROR("binary operator returned null");
     delete $2;
@@ -2885,7 +3011,7 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*$2, $5);
     CHECK_FOR_ERROR
-    $$ = BinaryOperator::create($1, tmpVal1, tmpVal2);
+    $$ = BinaryOperator::Create($1, tmpVal1, tmpVal2);
     if ($$ == 0)
       GEN_ERROR("binary operator returned null");
     delete $2;
@@ -2899,7 +3025,7 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*$3, $6);
     CHECK_FOR_ERROR
-    $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
     if ($$ == 0)
       GEN_ERROR("icmp operator returned null");
     delete $3;
@@ -2913,7 +3039,35 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*$3, $6);
     CHECK_FOR_ERROR
-    $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
+    if ($$ == 0)
+      GEN_ERROR("fcmp operator returned null");
+    delete $3;
+  }
+  | VICMP IPredicates Types ValueRef ',' ValueRef  {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
+    if (!isa<VectorType>((*$3).get()))
+      GEN_ERROR("Scalar types not supported by vicmp instruction");
+    Value* tmpVal1 = getVal(*$3, $4);
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*$3, $6);
+    CHECK_FOR_ERROR
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
+    if ($$ == 0)
+      GEN_ERROR("icmp operator returned null");
+    delete $3;
+  }
+  | VFCMP FPredicates Types ValueRef ',' ValueRef  {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
+    if (!isa<VectorType>((*$3).get()))
+      GEN_ERROR("Scalar types not supported by vfcmp instruction");
+    Value* tmpVal1 = getVal(*$3, $4);
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*$3, $6);
+    CHECK_FOR_ERROR
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
     if ($$ == 0)
       GEN_ERROR("fcmp operator returned null");
     delete $3;
@@ -2927,7 +3081,7 @@
       GEN_ERROR("invalid cast opcode for cast from '" +
                 Val->getType()->getDescription() + "' to '" +
                 DestTy->getDescription() + "'"); 
-    $$ = CastInst::create($1, Val, DestTy);
+    $$ = CastInst::Create($1, Val, DestTy);
     delete $4;
   }
   | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
@@ -2995,6 +3149,10 @@
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
       }
+
+      if (!FunctionType::isValidReturnType(*$3))
+        GEN_ERROR("Invalid result type for LLVM function");
+
       Ty = FunctionType::get($3->get(), ParamTypes, false);
       PFTy = PointerType::getUnqual(Ty);
     }
@@ -3090,6 +3248,8 @@
   | MALLOC Types ',' INTTYPE ValueRef OptCAlign {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if ($4 != Type::Int32Ty)
+      GEN_ERROR("Malloc array size is not a 32-bit integer!");
     Value* tmpVal = getVal($4, $5);
     CHECK_FOR_ERROR
     $$ = new MallocInst(*$2, tmpVal, $6);
@@ -3105,6 +3265,8 @@
   | ALLOCA Types ',' INTTYPE ValueRef OptCAlign {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if ($4 != Type::Int32Ty)
+      GEN_ERROR("Alloca array size is not a 32-bit integer!");
     Value* tmpVal = getVal($4, $5);
     CHECK_FOR_ERROR
     $$ = new AllocaInst(*$2, tmpVal, $6);
@@ -3149,7 +3311,7 @@
     $$ = new StoreInst($3, tmpVal, $1, $7);
     delete $5;
   }
-| GETRESULT Types SymbolicValueRef ',' EUINT64VAL  {
+  | GETRESULT Types ValueRef ',' EUINT64VAL  {
   Value *TmpVal = getVal($2->get(), $3);
   if (!GetResultInst::isValidOperands(TmpVal, $5))
       GEN_ERROR("Invalid getresult operands");
@@ -3163,7 +3325,7 @@
     if (!isa<PointerType>($2->get()))
       GEN_ERROR("getelementptr insn requires pointer operand");
 
-    if (!GetElementPtrInst::getIndexedType(*$2, $4->begin(), $4->end(), true))
+    if (!GetElementPtrInst::getIndexedType(*$2, $4->begin(), $4->end()))
       GEN_ERROR("Invalid getelementptr indices for type '" +
                      (*$2)->getDescription()+ "'");
     Value* tmpVal = getVal(*$2, $3);
@@ -3171,6 +3333,38 @@
     $$ = GetElementPtrInst::Create(tmpVal, $4->begin(), $4->end());
     delete $2; 
     delete $4;
+  }
+  | EXTRACTVALUE Types ValueRef ConstantIndexList {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if (!isa<StructType>($2->get()) && !isa<ArrayType>($2->get()))
+      GEN_ERROR("extractvalue insn requires an aggregate operand");
+
+    if (!ExtractValueInst::getIndexedType(*$2, $4->begin(), $4->end()))
+      GEN_ERROR("Invalid extractvalue indices for type '" +
+                     (*$2)->getDescription()+ "'");
+    Value* tmpVal = getVal(*$2, $3);
+    CHECK_FOR_ERROR
+    $$ = ExtractValueInst::Create(tmpVal, $4->begin(), $4->end());
+    delete $2; 
+    delete $4;
+  }
+  | INSERTVALUE Types ValueRef ',' Types ValueRef ConstantIndexList {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if (!isa<StructType>($2->get()) && !isa<ArrayType>($2->get()))
+      GEN_ERROR("extractvalue insn requires an aggregate operand");
+
+    if (ExtractValueInst::getIndexedType(*$2, $7->begin(), $7->end()) != $5->get())
+      GEN_ERROR("Invalid insertvalue indices for type '" +
+                     (*$2)->getDescription()+ "'");
+    Value* aggVal = getVal(*$2, $3);
+    Value* tmpVal = getVal(*$5, $6);
+    CHECK_FOR_ERROR
+    $$ = InsertValueInst::Create(aggVal, tmpVal, $7->begin(), $7->end());
+    delete $2; 
+    delete $5;
+    delete $7;
   };
 
 

Modified: llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y.cvs?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y.cvs (original)
+++ llvm/branches/non-call-eh/lib/AsmParser/llvmAsmParser.y.cvs Sun Jul  6 15:45:41 2008
@@ -475,7 +475,7 @@
   if (TriggerError) return 0;
 
   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
-    GenerateError("Invalid use of a composite type");
+    GenerateError("Invalid use of a non-first-class type");
     return 0;
   }
 
@@ -517,7 +517,7 @@
 
 /// defineBBVal - This is a definition of a new basic block with the specified
 /// identifier which must be the same as CurFun.NextValNum, if its numeric.
-static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) {
+static BasicBlock *defineBBVal(const ValID &ID) {
   assert(inFunctionScope() && "Can't get basic block at global scope!");
 
   BasicBlock *BB = 0;
@@ -559,7 +559,6 @@
   }
 
   ID.destroy();
-  BB->setUnwindDest(unwindDest);
   return BB;
 }
 
@@ -732,6 +731,10 @@
     GenerateError("Cannot declare global vars of function type");
     return 0;
   }
+  if (Ty == Type::LabelTy) {
+    GenerateError("Cannot declare global vars of label type");
+    return 0;
+  }
 
   const PointerType *PTy = PointerType::get(Ty, AddressSpace);
 
@@ -960,6 +963,7 @@
   llvm::PATypeHolder                     *TypeVal;
   llvm::Value                            *ValueVal;
   std::vector<llvm::Value*>              *ValueList;
+  std::vector<unsigned>                  *ConstantList;
   llvm::ArgListType                      *ArgList;
   llvm::TypeWithAttrs                     TypeWithAttrs;
   llvm::TypeWithAttrsList                *TypeWithAttrsList;
@@ -1005,6 +1009,7 @@
 %type <PHIList>       PHIList
 %type <ParamList>     ParamList      // For call param lists & GEP indices
 %type <ValueList>     IndexList         // For GEP indices
+%type <ConstantList>  ConstantIndexList // For insertvalue/extractvalue indices
 %type <TypeList>      TypeListI 
 %type <TypeWithAttrsList> ArgTypeList ArgTypeListI
 %type <TypeWithAttrs> ArgType
@@ -1059,11 +1064,11 @@
 %token ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
 %token DECLARE DEFINE GLOBAL CONSTANT SECTION ALIAS VOLATILE THREAD_LOCAL
 %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING
-%token DLLIMPORT DLLEXPORT EXTERN_WEAK
+%token DLLIMPORT DLLEXPORT EXTERN_WEAK COMMON
 %token OPAQUE EXTERNAL TARGET TRIPLE ALIGN ADDRSPACE
 %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
 %token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
-%token DATALAYOUT UNWINDS
+%token DATALAYOUT
 %type <UIntVal> OptCallingConv
 %type <ParamAttrs> OptParamAttrs ParamAttr 
 %type <ParamAttrs> OptFuncAttrs  FuncAttr
@@ -1076,7 +1081,7 @@
 %token <BinaryOpVal> ADD SUB MUL UDIV SDIV FDIV UREM SREM FREM AND OR XOR
 %token <BinaryOpVal> SHL LSHR ASHR
 
-%token <OtherOpVal> ICMP FCMP
+%token <OtherOpVal> ICMP FCMP VICMP VFCMP
 %type  <IPredicate> IPredicates
 %type  <FPredicate> FPredicates
 %token  EQ NE SLT SGT SLE SGE ULT UGT ULE UGE 
@@ -1094,6 +1099,7 @@
 %token <OtherOpVal> PHI_TOK SELECT VAARG
 %token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
 %token <OtherOpVal> GETRESULT
+%token <OtherOpVal> EXTRACTVALUE INSERTVALUE
 
 // Function Attributes
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
@@ -1175,6 +1181,7 @@
   | LINKONCE    { $$ = GlobalValue::LinkOnceLinkage; }
   | APPENDING   { $$ = GlobalValue::AppendingLinkage; }
   | DLLEXPORT   { $$ = GlobalValue::DLLExportLinkage; } 
+  | COMMON      { $$ = GlobalValue::CommonLinkage; }
   ;
 
 GVExternalLinkage
@@ -1349,12 +1356,10 @@
   | Types '(' ArgTypeListI ')' OptFuncAttrs {
     // Allow but ignore attributes on function types; this permits auto-upgrade.
     // FIXME: remove in LLVM 3.0.
-    const Type* RetTy = *$1;
-    if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
-          isa<StructType>(RetTy) ||
-          isa<OpaqueType>(RetTy)))
-      GEN_ERROR("LLVM Functions cannot return aggregates");
-
+    const Type *RetTy = *$1;
+    if (!FunctionType::isValidReturnType(RetTy))
+      GEN_ERROR("Invalid result type for LLVM function");
+      
     std::vector<const Type*> Params;
     TypeWithAttrsList::iterator I = $3->begin(), E = $3->end();
     for (; I != E; ++I ) {
@@ -1403,7 +1408,7 @@
   }
 
   | '[' EUINT64VAL 'x' Types ']' {          // Sized array type?
-    $$ = new PATypeHolder(HandleUpRefs(ArrayType::get(*$4, (unsigned)$2)));
+    $$ = new PATypeHolder(HandleUpRefs(ArrayType::get(*$4, $2)));
     delete $4;
     CHECK_FOR_ERROR
   }
@@ -1530,13 +1535,13 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'");
     const Type *ETy = ATy->getElementType();
-    int NumElements = ATy->getNumElements();
+    uint64_t NumElements = ATy->getNumElements();
 
     // Verify that we have the correct size...
-    if (NumElements != -1 && NumElements != (int)$3->size())
+    if (NumElements != uint64_t(-1) && NumElements != $3->size())
       GEN_ERROR("Type mismatch: constant sized array initialized with " +
                      utostr($3->size()) +  " arguments, but has size of " + 
-                     itostr(NumElements) + "");
+                     utostr(NumElements) + "");
 
     // Verify all elements are correct type!
     for (unsigned i = 0; i < $3->size(); i++) {
@@ -1558,10 +1563,10 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'");
 
-    int NumElements = ATy->getNumElements();
-    if (NumElements != -1 && NumElements != 0) 
+    uint64_t NumElements = ATy->getNumElements();
+    if (NumElements != uint64_t(-1) && NumElements != 0) 
       GEN_ERROR("Type mismatch: constant sized array initialized with 0"
-                     " arguments, but has size of " + itostr(NumElements) +"");
+                     " arguments, but has size of " + utostr(NumElements) +"");
     $$ = ConstantArray::get(ATy, std::vector<Constant*>());
     delete $1;
     CHECK_FOR_ERROR
@@ -1574,15 +1579,15 @@
       GEN_ERROR("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'");
 
-    int NumElements = ATy->getNumElements();
+    uint64_t NumElements = ATy->getNumElements();
     const Type *ETy = ATy->getElementType();
-    if (NumElements != -1 && NumElements != int($3->length()))
+    if (NumElements != uint64_t(-1) && NumElements != $3->length())
       GEN_ERROR("Can't build string constant of size " + 
-                     itostr((int)($3->length())) +
-                     " when array has size " + itostr(NumElements) + "");
+                     utostr($3->length()) +
+                     " when array has size " + utostr(NumElements) + "");
     std::vector<Constant*> Vals;
     if (ETy == Type::Int8Ty) {
-      for (unsigned i = 0; i < $3->length(); ++i)
+      for (uint64_t i = 0; i < $3->length(); ++i)
         Vals.push_back(ConstantInt::get(ETy, (*$3)[i]));
     } else {
       delete $3;
@@ -1601,13 +1606,13 @@
       GEN_ERROR("Cannot make packed constant with type: '" + 
                      (*$1)->getDescription() + "'");
     const Type *ETy = PTy->getElementType();
-    int NumElements = PTy->getNumElements();
+    unsigned NumElements = PTy->getNumElements();
 
     // Verify that we have the correct size...
-    if (NumElements != -1 && NumElements != (int)$3->size())
+    if (NumElements != unsigned(-1) && NumElements != (unsigned)$3->size())
       GEN_ERROR("Type mismatch: constant sized packed initialized with " +
                      utostr($3->size()) +  " arguments, but has size of " + 
-                     itostr(NumElements) + "");
+                     utostr(NumElements) + "");
 
     // Verify all elements are correct type!
     for (unsigned i = 0; i < $3->size(); i++) {
@@ -1851,12 +1856,14 @@
     CHECK_FOR_ERROR
   }
   | INTTYPE TRUETOK {                      // Boolean constants
-    assert(cast<IntegerType>($1)->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>($1)->getBitWidth() != 1)
+      GEN_ERROR("Constant true must have type i1");
     $$ = ConstantInt::getTrue();
     CHECK_FOR_ERROR
   }
   | INTTYPE FALSETOK {                     // Boolean constants
-    assert(cast<IntegerType>($1)->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>($1)->getBitWidth() != 1)
+      GEN_ERROR("Constant false must have type i1");
     $$ = ConstantInt::getFalse();
     CHECK_FOR_ERROR
   }
@@ -1890,8 +1897,7 @@
       GEN_ERROR("GetElementPtr requires a pointer operand");
 
     const Type *IdxTy =
-      GetElementPtrInst::getIndexedType($3->getType(), $4->begin(), $4->end(),
-                                        true);
+      GetElementPtrInst::getIndexedType($3->getType(), $4->begin(), $4->end());
     if (!IdxTy)
       GEN_ERROR("Index list invalid for constant getelementptr");
 
@@ -1942,6 +1948,16 @@
       GEN_ERROR("fcmp operand types must match");
     $$ = ConstantExpr::getFCmp($2, $4, $6);
   }
+  | VICMP IPredicates '(' ConstVal ',' ConstVal ')' {
+    if ($4->getType() != $6->getType())
+      GEN_ERROR("vicmp operand types must match");
+    $$ = ConstantExpr::getVICmp($2, $4, $6);
+  }
+  | VFCMP FPredicates '(' ConstVal ',' ConstVal ')' {
+    if ($4->getType() != $6->getType())
+      GEN_ERROR("vfcmp operand types must match");
+    $$ = ConstantExpr::getVFCmp($2, $4, $6);
+  }
   | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
     if (!ExtractElementInst::isValidOperands($3, $5))
       GEN_ERROR("Invalid extractelement operands");
@@ -1959,6 +1975,22 @@
       GEN_ERROR("Invalid shufflevector operands");
     $$ = ConstantExpr::getShuffleVector($3, $5, $7);
     CHECK_FOR_ERROR
+  }
+  | EXTRACTVALUE '(' ConstVal ConstantIndexList ')' {
+    if (!isa<StructType>($3->getType()) && !isa<ArrayType>($3->getType()))
+      GEN_ERROR("ExtractValue requires an aggregate operand");
+
+    $$ = ConstantExpr::getExtractValue($3, &(*$4)[0], $4->size());
+    delete $4;
+    CHECK_FOR_ERROR
+  }
+  | INSERTVALUE '(' ConstVal ',' ConstVal ConstantIndexList ')' {
+    if (!isa<StructType>($3->getType()) && !isa<ArrayType>($3->getType()))
+      GEN_ERROR("InsertValue requires an aggregate operand");
+
+    $$ = ConstantExpr::getInsertValue($3, $5, &(*$6)[0], $6->size());
+    delete $6;
+    CHECK_FOR_ERROR
   };
 
 
@@ -2200,8 +2232,8 @@
 ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
-    if (*$3 == Type::VoidTy)
-      GEN_ERROR("void typed arguments are invalid");
+    if (!(*$3)->isFirstClassType())
+      GEN_ERROR("Argument types must be first-class");
     ArgListEntry E; E.Attrs = $4; E.Ty = $3; E.Name = $5;
     $$ = $1;
     $1->push_back(E);
@@ -2210,8 +2242,8 @@
   | Types OptParamAttrs OptLocalName {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
-    if (*$1 == Type::VoidTy)
-      GEN_ERROR("void typed arguments are invalid");
+    if (!(*$1)->isFirstClassType())
+      GEN_ERROR("Argument types must be first-class");
     ArgListEntry E; E.Attrs = $2; E.Ty = $1; E.Name = $3;
     $$ = new ArgListType;
     $$->push_back(E);
@@ -2255,6 +2287,9 @@
   if (!CurFun.isDeclare && CurModule.TypeIsUnresolved($2))
     GEN_ERROR("Reference to abstract result: "+ $2->get()->getDescription());
 
+  if (!FunctionType::isValidReturnType(*$2))
+    GEN_ERROR("Invalid result type for LLVM function");
+    
   std::vector<const Type*> ParamTypeList;
   SmallVector<ParamAttrsWithIndex, 8> Attrs;
   if ($7 != ParamAttr::None)
@@ -2444,16 +2479,13 @@
   }
   | '<' ConstVector '>' { // Nonempty unsized packed vector
     const Type *ETy = (*$2)[0]->getType();
-    int NumElements = $2->size(); 
+    unsigned NumElements = $2->size(); 
+
+    if (!ETy->isInteger() && !ETy->isFloatingPoint())
+      GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
     
     VectorType* pt = VectorType::get(ETy, NumElements);
-    PATypeHolder* PTy = new PATypeHolder(
-                                         HandleUpRefs(
-                                            VectorType::get(
-                                                ETy, 
-                                                NumElements)
-                                            )
-                                         );
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
     
     // Verify all elements are correct type!
     for (unsigned i = 0; i < $2->size(); i++) {
@@ -2467,6 +2499,82 @@
     delete PTy; delete $2;
     CHECK_FOR_ERROR
   }
+  | '[' ConstVector ']' { // Nonempty unsized arr
+    const Type *ETy = (*$2)[0]->getType();
+    uint64_t NumElements = $2->size(); 
+
+    if (!ETy->isFirstClassType())
+      GEN_ERROR("Invalid array element type: " + ETy->getDescription());
+
+    ArrayType *ATy = ArrayType::get(ETy, NumElements);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
+
+    // Verify all elements are correct type!
+    for (unsigned i = 0; i < $2->size(); i++) {
+      if (ETy != (*$2)[i]->getType())
+        GEN_ERROR("Element #" + utostr(i) + " is not of type '" + 
+                       ETy->getDescription() +"' as required!\nIt is of type '"+
+                       (*$2)[i]->getType()->getDescription() + "'.");
+    }
+
+    $$ = ValID::create(ConstantArray::get(ATy, *$2));
+    delete PTy; delete $2;
+    CHECK_FOR_ERROR
+  }
+  | '[' ']' {
+    // Use undef instead of an array because it's inconvenient to determine
+    // the element type at this point, there being no elements to examine.
+    $$ = ValID::createUndef();
+    CHECK_FOR_ERROR
+  }
+  | 'c' STRINGCONSTANT {
+    uint64_t NumElements = $2->length();
+    const Type *ETy = Type::Int8Ty;
+
+    ArrayType *ATy = ArrayType::get(ETy, NumElements);
+
+    std::vector<Constant*> Vals;
+    for (unsigned i = 0; i < $2->length(); ++i)
+      Vals.push_back(ConstantInt::get(ETy, (*$2)[i]));
+    delete $2;
+    $$ = ValID::create(ConstantArray::get(ATy, Vals));
+    CHECK_FOR_ERROR
+  }
+  | '{' ConstVector '}' {
+    std::vector<const Type*> Elements($2->size());
+    for (unsigned i = 0, e = $2->size(); i != e; ++i)
+      Elements[i] = (*$2)[i]->getType();
+
+    const StructType *STy = StructType::get(Elements);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
+
+    $$ = ValID::create(ConstantStruct::get(STy, *$2));
+    delete PTy; delete $2;
+    CHECK_FOR_ERROR
+  }
+  | '{' '}' {
+    const StructType *STy = StructType::get(std::vector<const Type*>());
+    $$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
+    CHECK_FOR_ERROR
+  }
+  | '<' '{' ConstVector '}' '>' {
+    std::vector<const Type*> Elements($3->size());
+    for (unsigned i = 0, e = $3->size(); i != e; ++i)
+      Elements[i] = (*$3)[i]->getType();
+
+    const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
+    PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
+
+    $$ = ValID::create(ConstantStruct::get(STy, *$3));
+    delete PTy; delete $3;
+    CHECK_FOR_ERROR
+  }
+  | '<' '{' '}' '>' {
+    const StructType *STy = StructType::get(std::vector<const Type*>(),
+                                            /*isPacked=*/true);
+    $$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
+    CHECK_FOR_ERROR
+  }
   | ConstExpr {
     $$ = ValID::create($1);
     CHECK_FOR_ERROR
@@ -2558,22 +2666,14 @@
     CHECK_FOR_ERROR
   }
   | /* empty */ {          // Empty space between instruction lists
-    $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
-    CHECK_FOR_ERROR
-  }
-  | UNWINDS TO ValueRef {   // Only the unwind to block
-    $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal($3));
+    $$ = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
     CHECK_FOR_ERROR
   }
   | LABELSTR {             // Labelled (named) basic block
-    $$ = defineBBVal(ValID::createLocalName(*$1), 0);
-    delete $1;
-    CHECK_FOR_ERROR
-  }
-  | LABELSTR UNWINDS TO ValueRef {
-    $$ = defineBBVal(ValID::createLocalName(*$1), getBBVal($4));
+    $$ = defineBBVal(ValID::createLocalName(*$1));
     delete $1;
     CHECK_FOR_ERROR
+
   };
 
 BBTerminatorInst : 
@@ -2594,7 +2694,8 @@
     $$ = BranchInst::Create(tmpBB);
   }                                               // Conditional Branch...
   | BR INTTYPE ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {  
-    assert(cast<IntegerType>($2)->getBitWidth() == 1 && "Not Bool?");
+    if (cast<IntegerType>($2)->getBitWidth() != 1)
+      GEN_ERROR("Branch condition must have type i1");
     BasicBlock* tmpBBA = getBBVal($6);
     CHECK_FOR_ERROR
     BasicBlock* tmpBBB = getBBVal($9);
@@ -2648,6 +2749,10 @@
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
       }
+      
+      if (!FunctionType::isValidReturnType(*$3))
+        GEN_ERROR("Invalid result type for LLVM function");
+
       Ty = FunctionType::get($3->get(), ParamTypes, false);
       PFTy = PointerType::getUnqual(Ty);
     }
@@ -2705,7 +2810,8 @@
       PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
 
     // Create the InvokeInst
-    InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
+    InvokeInst *II = InvokeInst::Create(V, Normal, Except,
+                                        Args.begin(), Args.end());
     II->setCallingConv($2);
     II->setParamAttrs(PAL);
     $$ = II;
@@ -2825,6 +2931,22 @@
   }
   ;
 
+ConstantIndexList       // Used for insertvalue and extractvalue instructions
+  : ',' EUINT64VAL {
+    $$ = new std::vector<unsigned>();
+    if ((unsigned)$2 != $2)
+      GEN_ERROR("Index " + utostr($2) + " is not valid for insertvalue or extractvalue.");
+    $$->push_back($2);
+  }
+  | ConstantIndexList ',' EUINT64VAL {
+    $$ = $1;
+    if ((unsigned)$3 != $3)
+      GEN_ERROR("Index " + utostr($3) + " is not valid for insertvalue or extractvalue.");
+    $$->push_back($3);
+    CHECK_FOR_ERROR
+  }
+  ;
+
 OptTailCall : TAIL CALL {
     $$ = true;
     CHECK_FOR_ERROR
@@ -2845,7 +2967,7 @@
     CHECK_FOR_ERROR
     Value* val2 = getVal(*$2, $5);
     CHECK_FOR_ERROR
-    $$ = BinaryOperator::create($1, val1, val2);
+    $$ = BinaryOperator::Create($1, val1, val2);
     if ($$ == 0)
       GEN_ERROR("binary operator returned null");
     delete $2;
@@ -2862,7 +2984,7 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*$2, $5);
     CHECK_FOR_ERROR
-    $$ = BinaryOperator::create($1, tmpVal1, tmpVal2);
+    $$ = BinaryOperator::Create($1, tmpVal1, tmpVal2);
     if ($$ == 0)
       GEN_ERROR("binary operator returned null");
     delete $2;
@@ -2876,7 +2998,7 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*$3, $6);
     CHECK_FOR_ERROR
-    $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
     if ($$ == 0)
       GEN_ERROR("icmp operator returned null");
     delete $3;
@@ -2890,7 +3012,35 @@
     CHECK_FOR_ERROR
     Value* tmpVal2 = getVal(*$3, $6);
     CHECK_FOR_ERROR
-    $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2);
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
+    if ($$ == 0)
+      GEN_ERROR("fcmp operator returned null");
+    delete $3;
+  }
+  | VICMP IPredicates Types ValueRef ',' ValueRef  {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
+    if (!isa<VectorType>((*$3).get()))
+      GEN_ERROR("Scalar types not supported by vicmp instruction");
+    Value* tmpVal1 = getVal(*$3, $4);
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*$3, $6);
+    CHECK_FOR_ERROR
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
+    if ($$ == 0)
+      GEN_ERROR("icmp operator returned null");
+    delete $3;
+  }
+  | VFCMP FPredicates Types ValueRef ',' ValueRef  {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
+    if (!isa<VectorType>((*$3).get()))
+      GEN_ERROR("Scalar types not supported by vfcmp instruction");
+    Value* tmpVal1 = getVal(*$3, $4);
+    CHECK_FOR_ERROR
+    Value* tmpVal2 = getVal(*$3, $6);
+    CHECK_FOR_ERROR
+    $$ = CmpInst::Create($1, $2, tmpVal1, tmpVal2);
     if ($$ == 0)
       GEN_ERROR("fcmp operator returned null");
     delete $3;
@@ -2904,7 +3054,7 @@
       GEN_ERROR("invalid cast opcode for cast from '" +
                 Val->getType()->getDescription() + "' to '" +
                 DestTy->getDescription() + "'"); 
-    $$ = CastInst::create($1, Val, DestTy);
+    $$ = CastInst::Create($1, Val, DestTy);
     delete $4;
   }
   | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
@@ -2972,6 +3122,10 @@
           GEN_ERROR("Short call syntax cannot be used with varargs");
         ParamTypes.push_back(Ty);
       }
+
+      if (!FunctionType::isValidReturnType(*$3))
+        GEN_ERROR("Invalid result type for LLVM function");
+
       Ty = FunctionType::get($3->get(), ParamTypes, false);
       PFTy = PointerType::getUnqual(Ty);
     }
@@ -3067,6 +3221,8 @@
   | MALLOC Types ',' INTTYPE ValueRef OptCAlign {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if ($4 != Type::Int32Ty)
+      GEN_ERROR("Malloc array size is not a 32-bit integer!");
     Value* tmpVal = getVal($4, $5);
     CHECK_FOR_ERROR
     $$ = new MallocInst(*$2, tmpVal, $6);
@@ -3082,6 +3238,8 @@
   | ALLOCA Types ',' INTTYPE ValueRef OptCAlign {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if ($4 != Type::Int32Ty)
+      GEN_ERROR("Alloca array size is not a 32-bit integer!");
     Value* tmpVal = getVal($4, $5);
     CHECK_FOR_ERROR
     $$ = new AllocaInst(*$2, tmpVal, $6);
@@ -3126,7 +3284,7 @@
     $$ = new StoreInst($3, tmpVal, $1, $7);
     delete $5;
   }
-| GETRESULT Types SymbolicValueRef ',' EUINT64VAL  {
+  | GETRESULT Types ValueRef ',' EUINT64VAL  {
   Value *TmpVal = getVal($2->get(), $3);
   if (!GetResultInst::isValidOperands(TmpVal, $5))
       GEN_ERROR("Invalid getresult operands");
@@ -3140,7 +3298,7 @@
     if (!isa<PointerType>($2->get()))
       GEN_ERROR("getelementptr insn requires pointer operand");
 
-    if (!GetElementPtrInst::getIndexedType(*$2, $4->begin(), $4->end(), true))
+    if (!GetElementPtrInst::getIndexedType(*$2, $4->begin(), $4->end()))
       GEN_ERROR("Invalid getelementptr indices for type '" +
                      (*$2)->getDescription()+ "'");
     Value* tmpVal = getVal(*$2, $3);
@@ -3148,6 +3306,38 @@
     $$ = GetElementPtrInst::Create(tmpVal, $4->begin(), $4->end());
     delete $2; 
     delete $4;
+  }
+  | EXTRACTVALUE Types ValueRef ConstantIndexList {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if (!isa<StructType>($2->get()) && !isa<ArrayType>($2->get()))
+      GEN_ERROR("extractvalue insn requires an aggregate operand");
+
+    if (!ExtractValueInst::getIndexedType(*$2, $4->begin(), $4->end()))
+      GEN_ERROR("Invalid extractvalue indices for type '" +
+                     (*$2)->getDescription()+ "'");
+    Value* tmpVal = getVal(*$2, $3);
+    CHECK_FOR_ERROR
+    $$ = ExtractValueInst::Create(tmpVal, $4->begin(), $4->end());
+    delete $2; 
+    delete $4;
+  }
+  | INSERTVALUE Types ValueRef ',' Types ValueRef ConstantIndexList {
+    if (!UpRefs.empty())
+      GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
+    if (!isa<StructType>($2->get()) && !isa<ArrayType>($2->get()))
+      GEN_ERROR("extractvalue insn requires an aggregate operand");
+
+    if (ExtractValueInst::getIndexedType(*$2, $7->begin(), $7->end()) != $5->get())
+      GEN_ERROR("Invalid insertvalue indices for type '" +
+                     (*$2)->getDescription()+ "'");
+    Value* aggVal = getVal(*$2, $3);
+    Value* tmpVal = getVal(*$5, $6);
+    CHECK_FOR_ERROR
+    $$ = InsertValueInst::Create(aggVal, tmpVal, $7->begin(), $7->end());
+    delete $2; 
+    delete $5;
+    delete $7;
   };
 
 

Modified: llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.cpp Sun Jul  6 15:45:41 2008
@@ -23,6 +23,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/OperandTraits.h"
 using namespace llvm;
 
 void BitcodeReader::FreeState() {
@@ -65,6 +66,7 @@
   case 5: return GlobalValue::DLLImportLinkage;
   case 6: return GlobalValue::DLLExportLinkage;
   case 7: return GlobalValue::ExternalWeakLinkage;
+  case 8: return GlobalValue::CommonLinkage;
   }
 }
 
@@ -115,55 +117,81 @@
   }
 }
 
-
+namespace llvm {
 namespace {
   /// @brief A class for maintaining the slot number definition
   /// as a placeholder for the actual definition for forward constants defs.
   class ConstantPlaceHolder : public ConstantExpr {
     ConstantPlaceHolder();                       // DO NOT IMPLEMENT
     void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
-    Use Op;
   public:
     // allocate space for exactly one operand
     void *operator new(size_t s) {
       return User::operator new(s, 1);
     }
     explicit ConstantPlaceHolder(const Type *Ty)
-      : ConstantExpr(Ty, Instruction::UserOp1, &Op, 1),
-        Op(UndefValue::get(Type::Int32Ty), this) {
+      : ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) {
+      Op<0>() = UndefValue::get(Type::Int32Ty);
     }
+    /// Provide fast operand accessors
+    DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
   };
 }
 
+
+  // FIXME: can we inherit this from ConstantExpr?
+template <>
+struct OperandTraits<ConstantPlaceHolder> : FixedNumOperandTraits<1> {
+};
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value)
+}
+
+void BitcodeReaderValueList::resize(unsigned Desired) {
+  if (Desired > Capacity) {
+    // Since we expect many values to come from the bitcode file we better
+    // allocate the double amount, so that the array size grows exponentially
+    // at each reallocation.  Also, add a small amount of 100 extra elements
+    // each time, to reallocate less frequently when the array is still small.
+    //
+    Capacity = Desired * 2 + 100;
+    Use *New = allocHungoffUses(Capacity);
+    Use *Old = OperandList;
+    unsigned Ops = getNumOperands();
+    for (int i(Ops - 1); i >= 0; --i)
+      New[i] = Old[i].get();
+    OperandList = New;
+    if (Old) Use::zap(Old, Old + Ops, true);
+  }
+}
+
 Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx,
                                                     const Type *Ty) {
   if (Idx >= size()) {
     // Insert a bunch of null values.
-    Uses.resize(Idx+1);
-    OperandList = &Uses[0];
+    resize(Idx + 1);
     NumOperands = Idx+1;
   }
 
-  if (Value *V = Uses[Idx]) {
+  if (Value *V = OperandList[Idx]) {
     assert(Ty == V->getType() && "Type mismatch in constant table!");
     return cast<Constant>(V);
   }
 
   // Create and return a placeholder, which will later be RAUW'd.
   Constant *C = new ConstantPlaceHolder(Ty);
-  Uses[Idx].init(C, this);
+  OperandList[Idx] = C;
   return C;
 }
 
 Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, const Type *Ty) {
   if (Idx >= size()) {
     // Insert a bunch of null values.
-    Uses.resize(Idx+1);
-    OperandList = &Uses[0];
+    resize(Idx + 1);
     NumOperands = Idx+1;
   }
   
-  if (Value *V = Uses[Idx]) {
+  if (Value *V = OperandList[Idx]) {
     assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!");
     return V;
   }
@@ -173,7 +201,7 @@
   
   // Create and return a placeholder, which will later be RAUW'd.
   Value *V = new Argument(Ty);
-  Uses[Idx].init(V, this);
+  OperandList[Idx] = V;
   return V;
 }
 
@@ -742,6 +770,47 @@
       V = ConstantExpr::getGetElementPtr(Elts[0], &Elts[1], Elts.size()-1);
       break;
     }
+    case bitc::CST_CODE_CE_EXTRACTVAL: {
+                                    // CE_EXTRACTVAL: [opty, opval, n x indices]
+      const Type *AggTy = getTypeByID(Record[0]);
+      if (!AggTy || !AggTy->isAggregateType())
+        return Error("Invalid CE_EXTRACTVAL record");
+      Constant *Agg = ValueList.getConstantFwdRef(Record[1], AggTy);
+      SmallVector<unsigned, 4> Indices;
+      for (unsigned i = 2, e = Record.size(); i != e; ++i) {
+        uint64_t Index = Record[i];
+        if ((unsigned)Index != Index)
+          return Error("Invalid CE_EXTRACTVAL record");
+        Indices.push_back((unsigned)Index);
+      }
+      if (!ExtractValueInst::getIndexedType(AggTy,
+                                            Indices.begin(), Indices.end()))
+        return Error("Invalid CE_EXTRACTVAL record");
+      V = ConstantExpr::getExtractValue(Agg, &Indices[0], Indices.size());
+      break;
+    }
+    case bitc::CST_CODE_CE_INSERTVAL: {
+                        // CE_INSERTVAL: [opty, opval, opty, opval, n x indices]
+      const Type *AggTy = getTypeByID(Record[0]);
+      if (!AggTy || !AggTy->isAggregateType())
+        return Error("Invalid CE_INSERTVAL record");
+      Constant *Agg = ValueList.getConstantFwdRef(Record[1], AggTy);
+      const Type *ValTy = getTypeByID(Record[2]);
+      Constant *Val = ValueList.getConstantFwdRef(Record[3], ValTy);
+      SmallVector<unsigned, 4> Indices;
+      for (unsigned i = 4, e = Record.size(); i != e; ++i) {
+        uint64_t Index = Record[i];
+        if ((unsigned)Index != Index)
+          return Error("Invalid CE_INSERTVAL record");
+        Indices.push_back((unsigned)Index);
+      }
+      if (ExtractValueInst::getIndexedType(AggTy,
+                                           Indices.begin(),
+                                           Indices.end()) != ValTy)
+        return Error("Invalid CE_INSERTVAL record");
+      V = ConstantExpr::getInsertValue(Agg, Val, &Indices[0], Indices.size());
+      break;
+    }
     case bitc::CST_CODE_CE_SELECT:  // CE_SELECT: [opval#, opval#, opval#]
       if (Record.size() < 3) return Error("Invalid CE_SELECT record");
       V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
@@ -791,8 +860,12 @@
 
       if (OpTy->isFloatingPoint())
         V = ConstantExpr::getFCmp(Record[3], Op0, Op1);
-      else
+      else if (!isa<VectorType>(OpTy))
         V = ConstantExpr::getICmp(Record[3], Op0, Op1);
+      else if (OpTy->isFPOrFPVector())
+        V = ConstantExpr::getVFCmp(Record[3], Op0, Op1);
+      else
+        V = ConstantExpr::getVICmp(Record[3], Op0, Op1);
       break;
     }
     case bitc::CST_CODE_INLINEASM: {
@@ -1224,15 +1297,6 @@
       CurBB = FunctionBBs[0];
       continue;
       
-    case bitc::FUNC_CODE_INST_BB_UNWINDDEST:   // BB_UNWINDDEST: [bb#]
-      if (CurBB->getUnwindDest())
-        return Error("Only permit one BB_UNWINDDEST per BB");
-      if (Record.size() != 1)
-        return Error("Invalid BB_UNWINDDEST record");
-
-      CurBB->setUnwindDest(getBasicBlock(Record[0]));
-      continue;
-      
     case bitc::FUNC_CODE_INST_BB_NOUNWIND:    // BB_NOUNWIND
       CurBB->setDoesNotThrow();
       continue;
@@ -1247,7 +1311,7 @@
       
       int Opc = GetDecodedBinaryOpcode(Record[OpNum], LHS->getType());
       if (Opc == -1) return Error("Invalid BINOP record");
-      I = BinaryOperator::create((Instruction::BinaryOps)Opc, LHS, RHS);
+      I = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS);
       break;
     }
     case bitc::FUNC_CODE_INST_CAST: {    // CAST: [opval, opty, destty, castopc]
@@ -1261,7 +1325,7 @@
       int Opc = GetDecodedCastOpcode(Record[OpNum+1]);
       if (Opc == -1 || ResTy == 0)
         return Error("Invalid CAST record");
-      I = CastInst::create((Instruction::CastOps)Opc, Op, ResTy);
+      I = CastInst::Create((Instruction::CastOps)Opc, Op, ResTy);
       break;
     }
     case bitc::FUNC_CODE_INST_GEP: { // GEP: [n x operands]
@@ -1282,6 +1346,51 @@
       break;
     }
       
+    case bitc::FUNC_CODE_INST_EXTRACTVAL: {
+                                       // EXTRACTVAL: [opty, opval, n x indices]
+      unsigned OpNum = 0;
+      Value *Agg;
+      if (getValueTypePair(Record, OpNum, NextValueNo, Agg))
+        return Error("Invalid EXTRACTVAL record");
+
+      SmallVector<unsigned, 4> EXTRACTVALIdx;
+      for (unsigned RecSize = Record.size();
+           OpNum != RecSize; ++OpNum) {
+        uint64_t Index = Record[OpNum];
+        if ((unsigned)Index != Index)
+          return Error("Invalid EXTRACTVAL index");
+        EXTRACTVALIdx.push_back((unsigned)Index);
+      }
+
+      I = ExtractValueInst::Create(Agg,
+                                   EXTRACTVALIdx.begin(), EXTRACTVALIdx.end());
+      break;
+    }
+      
+    case bitc::FUNC_CODE_INST_INSERTVAL: {
+                           // INSERTVAL: [opty, opval, opty, opval, n x indices]
+      unsigned OpNum = 0;
+      Value *Agg;
+      if (getValueTypePair(Record, OpNum, NextValueNo, Agg))
+        return Error("Invalid INSERTVAL record");
+      Value *Val;
+      if (getValueTypePair(Record, OpNum, NextValueNo, Val))
+        return Error("Invalid INSERTVAL record");
+
+      SmallVector<unsigned, 4> INSERTVALIdx;
+      for (unsigned RecSize = Record.size();
+           OpNum != RecSize; ++OpNum) {
+        uint64_t Index = Record[OpNum];
+        if ((unsigned)Index != Index)
+          return Error("Invalid INSERTVAL index");
+        INSERTVALIdx.push_back((unsigned)Index);
+      }
+
+      I = InsertValueInst::Create(Agg, Val,
+                                  INSERTVALIdx.begin(), INSERTVALIdx.end());
+      break;
+    }
+      
     case bitc::FUNC_CODE_INST_SELECT: { // SELECT: [opval, ty, opval, opval]
       unsigned OpNum = 0;
       Value *TrueVal, *FalseVal, *Cond;
@@ -1341,10 +1450,14 @@
           OpNum+1 != Record.size())
         return Error("Invalid CMP record");
       
-      if (LHS->getType()->isFPOrFPVector())
+      if (LHS->getType()->isFloatingPoint())
         I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS);
-      else
+      else if (!isa<VectorType>(LHS->getType()))
         I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS);
+      else if (LHS->getType()->isFPOrFPVector())
+        I = new VFCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS);
+      else
+        I = new VICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS);
       break;
     }
     case bitc::FUNC_CODE_INST_GETRESULT: { // GETRESULT: [ty, val, n]
@@ -1462,7 +1575,8 @@
         }
       }
       
-      I = InvokeInst::Create(Callee, NormalBB, UnwindBB, Ops.begin(), Ops.end());
+      I = InvokeInst::Create(Callee, NormalBB, UnwindBB,
+                             Ops.begin(), Ops.end());
       cast<InvokeInst>(I)->setCallingConv(CCInfo);
       cast<InvokeInst>(I)->setParamAttrs(PAL);
       break;

Modified: llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.h?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.h (original)
+++ llvm/branches/non-call-eh/lib/Bitcode/Reader/BitcodeReader.h Sun Jul  6 15:45:41 2008
@@ -17,7 +17,7 @@
 #include "llvm/ModuleProvider.h"
 #include "llvm/ParameterAttributes.h"
 #include "llvm/Type.h"
-#include "llvm/User.h"
+#include "llvm/OperandTraits.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/ADT/DenseMap.h"
@@ -26,32 +26,43 @@
 namespace llvm {
   class MemoryBuffer;
   
+//===----------------------------------------------------------------------===//
+//                          BitcodeReaderValueList Class
+//===----------------------------------------------------------------------===//
+
 class BitcodeReaderValueList : public User {
-  std::vector<Use> Uses;
+  unsigned Capacity;
 public:
-  BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {}
-  
+  BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0)
+                           , Capacity(0) {}
+
+  /// Provide fast operand accessors
+  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
   // vector compatibility methods
   unsigned size() const { return getNumOperands(); }
+  void resize(unsigned);
   void push_back(Value *V) {
-    Uses.push_back(Use(V, this));
-    OperandList = &Uses[0];
-    ++NumOperands;
+    unsigned OldOps(NumOperands), NewOps(NumOperands + 1);
+    resize(NewOps);
+    NumOperands = NewOps;
+    OperandList[OldOps] = V;
   }
   
   void clear() {
-    std::vector<Use>().swap(Uses);
+    if (OperandList) dropHungoffUses(OperandList);
+    Capacity = 0;
   }
   
   Value *operator[](unsigned i) const { return getOperand(i); }
   
-  Value *back() const { return Uses.back(); }
-  void pop_back() { Uses.pop_back(); --NumOperands; }
+  Value *back() const { return getOperand(size() - 1); }
+  void pop_back() { setOperand(size() - 1, 0); --NumOperands; }
   bool empty() const { return NumOperands == 0; }
   void shrinkTo(unsigned N) {
     assert(N <= NumOperands && "Invalid shrinkTo request!");
-    Uses.resize(N);
-    NumOperands = N;
+    while (NumOperands > N)
+      pop_back();
   }
   virtual void print(std::ostream&) const {}
   
@@ -73,11 +84,20 @@
   
 private:
   void initVal(unsigned Idx, Value *V) {
-    assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!");
-    Uses[Idx].init(V, this);
+    if (Idx >= size()) {
+      // Insert a bunch of null values.
+      resize(Idx * 2 + 1);
+    }
+    assert(getOperand(Idx) == 0 && "Cannot init an already init'd Use!");
+    OperandList[Idx] = V;
   }
 };
-  
+
+template <>
+struct OperandTraits<BitcodeReaderValueList> : HungoffOperandTraits</*16 FIXME*/> {
+};
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BitcodeReaderValueList, Value)  
 
 class BitcodeReader : public ModuleProvider {
   MemoryBuffer *Buffer;

Modified: llvm/branches/non-call-eh/lib/Bitcode/Reader/Deserialize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Reader/Deserialize.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Bitcode/Reader/Deserialize.cpp (original)
+++ llvm/branches/non-call-eh/lib/Bitcode/Reader/Deserialize.cpp Sun Jul  6 15:45:41 2008
@@ -85,7 +85,7 @@
         
       case bitc::END_BLOCK: {
         bool x = Stream.ReadBlockEnd();
-        assert (!x && "Error at block end.");
+        assert(!x && "Error at block end."); x=x;
         BlockStack.pop_back();
         continue;
       }

Modified: llvm/branches/non-call-eh/lib/Bitcode/Writer/BitWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Writer/BitWriter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Bitcode/Writer/BitWriter.cpp (original)
+++ llvm/branches/non-call-eh/lib/Bitcode/Writer/BitWriter.cpp Sun Jul  6 15:45:41 2008
@@ -28,7 +28,7 @@
   return 0;
 }
 
-#ifdef __GNUC__
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR >= 4)
 #include <ext/stdio_filebuf.h>
 
 // FIXME: Control this with configure? Provide some portable abstraction in
@@ -49,4 +49,10 @@
   return 0;
 }
 
+#else
+
+int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int FileHandle) {
+  return -1; // Not supported.
+}
+
 #endif

Modified: llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/branches/non-call-eh/lib/Bitcode/Writer/BitcodeWriter.cpp Sun Jul  6 15:45:41 2008
@@ -23,6 +23,7 @@
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/ValueSymbolTable.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/System/Program.h"
 using namespace llvm;
 
 /// These are manifest constants used by the bitcode writer. They do not need to
@@ -270,6 +271,7 @@
   case GlobalValue::DLLImportLinkage:    return 5;
   case GlobalValue::DLLExportLinkage:    return 6;
   case GlobalValue::ExternalWeakLinkage: return 7;
+  case GlobalValue::CommonLinkage:       return 8;
   }
 }
 
@@ -352,7 +354,7 @@
                               Log2_32_Ceil(MaxGlobalType+1)));
     Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));      // Constant.
     Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));        // Initializer.
-    Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));      // Linkage.
+    Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));      // Linkage.
     if (MaxAlignment == 0)                                      // Alignment.
       Abbv->Add(BitCodeAbbrevOp(0));
     else {
@@ -609,6 +611,26 @@
           Record.push_back(VE.getValueID(C->getOperand(i)));
         }
         break;
+      case Instruction::ExtractValue: {
+        Code = bitc::CST_CODE_CE_EXTRACTVAL;
+        Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
+        Record.push_back(VE.getValueID(C->getOperand(0)));
+        const SmallVector<unsigned, 4> &Indices = CE->getIndices();
+        for (unsigned i = 0, e = Indices.size(); i != e; ++i)
+          Record.push_back(Indices[i]);
+        break;
+      }
+      case Instruction::InsertValue: {
+        Code = bitc::CST_CODE_CE_INSERTVAL;
+        Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
+        Record.push_back(VE.getValueID(C->getOperand(0)));
+        Record.push_back(VE.getTypeID(C->getOperand(1)->getType()));
+        Record.push_back(VE.getValueID(C->getOperand(1)));
+        const SmallVector<unsigned, 4> &Indices = CE->getIndices();
+        for (unsigned i = 0, e = Indices.size(); i != e; ++i)
+          Record.push_back(Indices[i]);
+        break;
+      }
       case Instruction::Select:
         Code = bitc::CST_CODE_CE_SELECT;
         Record.push_back(VE.getValueID(C->getOperand(0)));
@@ -635,6 +657,8 @@
         break;
       case Instruction::ICmp:
       case Instruction::FCmp:
+      case Instruction::VICmp:
+      case Instruction::VFCmp:
         Code = bitc::CST_CODE_CE_CMP;
         Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
         Record.push_back(VE.getValueID(C->getOperand(0)));
@@ -715,6 +739,23 @@
     for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
       PushValueAndType(I.getOperand(i), InstID, Vals, VE);
     break;
+  case Instruction::ExtractValue: {
+    Code = bitc::FUNC_CODE_INST_EXTRACTVAL;
+    PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+    const ExtractValueInst *EVI = cast<ExtractValueInst>(&I);
+    for (const unsigned *i = EVI->idx_begin(), *e = EVI->idx_end(); i != e; ++i)
+      Vals.push_back(*i);
+    break;
+  }
+  case Instruction::InsertValue: {
+    Code = bitc::FUNC_CODE_INST_INSERTVAL;
+    PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+    PushValueAndType(I.getOperand(1), InstID, Vals, VE);
+    const InsertValueInst *IVI = cast<InsertValueInst>(&I);
+    for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i)
+      Vals.push_back(*i);
+    break;
+  }
   case Instruction::Select:
     Code = bitc::FUNC_CODE_INST_SELECT;
     PushValueAndType(I.getOperand(1), InstID, Vals, VE);
@@ -740,6 +781,8 @@
     break;
   case Instruction::ICmp:
   case Instruction::FCmp:
+  case Instruction::VICmp:
+  case Instruction::VFCmp:
     Code = bitc::FUNC_CODE_INST_CMP;
     PushValueAndType(I.getOperand(0), InstID, Vals, VE);
     Vals.push_back(VE.getValueID(I.getOperand(1)));
@@ -987,7 +1030,6 @@
       if (I->getType() != Type::VoidTy)
         ++InstID;
     }
-  }
   
   // Emit names for all the instructions etc.
   WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
@@ -1261,6 +1303,10 @@
   // Emit the module.
   WriteModule(M, Stream);
   
+  // If writing to stdout, set binary mode.
+  if (llvm::cout == Out)
+      sys::Program::ChangeStdoutToBinary();
+
   // Write the generated bitstream to "Out".
   Out.write((char*)&Buffer.front(), Buffer.size());
   

Modified: llvm/branches/non-call-eh/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/branches/non-call-eh/lib/Bitcode/Writer/ValueEnumerator.cpp Sun Jul  6 15:45:41 2008
@@ -21,9 +21,9 @@
 #include <algorithm>
 using namespace llvm;
 
-static bool isFirstClassType(const std::pair<const llvm::Type*,
-                             unsigned int> &P) {
-  return P.first->isFirstClassType();
+static bool isSingleValueType(const std::pair<const llvm::Type*,
+                              unsigned int> &P) {
+  return P.first->isSingleValueType();
 }
 
 static bool isIntegerValue(const std::pair<const Value*, unsigned> &V) {
@@ -103,10 +103,10 @@
   // in the table (have low bit-width).
   std::stable_sort(Types.begin(), Types.end(), CompareByFrequency);
     
-  // Partition the Type ID's so that the first-class types occur before the
+  // Partition the Type ID's so that the single-value types occur before the
   // aggregate types.  This allows the aggregate types to be dropped from the
   // type table after parsing the global variable initializers.
-  std::partition(Types.begin(), Types.end(), isFirstClassType);
+  std::partition(Types.begin(), Types.end(), isSingleValueType);
 
   // Now that we rearranged the type table, rebuild TypeMap.
   for (unsigned i = 0, e = Types.size(); i != e; ++i)
@@ -114,19 +114,21 @@
 }
 
 // Optimize constant ordering.
-struct CstSortPredicate {
-  ValueEnumerator &VE;
-  CstSortPredicate(ValueEnumerator &ve) : VE(ve) {}
-  bool operator()(const std::pair<const Value*, unsigned> &LHS,
-                  const std::pair<const Value*, unsigned> &RHS) {
-    // Sort by plane.
-    if (LHS.first->getType() != RHS.first->getType())
-      return VE.getTypeID(LHS.first->getType()) < 
-             VE.getTypeID(RHS.first->getType());
-    // Then by frequency.
-    return LHS.second > RHS.second;
-  }
-};
+namespace {
+  struct CstSortPredicate {
+    ValueEnumerator &VE;
+    explicit CstSortPredicate(ValueEnumerator &ve) : VE(ve) {}
+    bool operator()(const std::pair<const Value*, unsigned> &LHS,
+                    const std::pair<const Value*, unsigned> &RHS) {
+      // Sort by plane.
+      if (LHS.first->getType() != RHS.first->getType())
+        return VE.getTypeID(LHS.first->getType()) < 
+               VE.getTypeID(RHS.first->getType());
+      // Then by frequency.
+      return LHS.second > RHS.second;
+    }
+  };
+}
 
 /// OptimizeConstants - Reorder constant pool for denser encoding.
 void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
@@ -262,11 +264,11 @@
 /// there are none, return -1.
 int ValueEnumerator::PurgeAggregateValues() {
   // If there are no aggregate values at the end of the list, return -1.
-  if (Values.empty() || Values.back().first->getType()->isFirstClassType())
+  if (Values.empty() || Values.back().first->getType()->isSingleValueType())
     return -1;
   
   // Otherwise, remove aggregate values...
-  while (!Values.empty() && !Values.back().first->getType()->isFirstClassType())
+  while (!Values.empty() && !Values.back().first->getType()->isSingleValueType())
     Values.pop_back();
   
   // ... and return the new size.

Modified: llvm/branches/non-call-eh/lib/CodeGen/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/AsmPrinter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/AsmPrinter.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/AsmPrinter.cpp Sun Jul  6 15:45:41 2008
@@ -21,7 +21,6 @@
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Streams.h"
@@ -29,14 +28,12 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include <cerrno>
 using namespace llvm;
 
-static cl::opt<bool>
-AsmVerbose("asm-verbose", cl::Hidden, cl::desc("Add comments to directives."));
-
 char AsmPrinter::ID = 0;
 AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
                        const TargetAsmInfo *T)
@@ -66,7 +63,7 @@
 
   // Close the current section, if applicable.
   if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty())
-    O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << "\n";
+    O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n';
 
   CurrentSection = NS;
 
@@ -92,7 +89,7 @@
 
   // Close the current section, if applicable.
   if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty())
-    O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << "\n";
+    O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n';
 
   CurrentSection = NS;
   
@@ -120,7 +117,7 @@
   if (!M.getModuleInlineAsm().empty())
     O << TAI->getCommentString() << " Start of file scope inline assembly\n"
       << M.getModuleInlineAsm()
-      << "\n" << TAI->getCommentString()
+      << '\n' << TAI->getCommentString()
       << " End of file scope inline assembly\n";
 
   SwitchToDataSection("");   // Reset back to no section.
@@ -140,7 +137,7 @@
          e = ExtWeakSymbols.end(); i != e; ++i) {
       const GlobalValue *GV = *i;
       std::string Name = Mang->getValueName(GV);
-      O << TAI->getWeakRefDirective() << Name << "\n";
+      O << TAI->getWeakRefDirective() << Name << '\n';
     }
   }
 
@@ -148,7 +145,7 @@
     if (!M.alias_empty())
       SwitchToTextSection(TAI->getTextSection());
 
-    O << "\n";
+    O << '\n';
     for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
          I!=E; ++I) {
       std::string Name = Mang->getValueName(I);
@@ -158,30 +155,30 @@
       Target = Mang->getValueName(GV);
       
       if (I->hasExternalLinkage() || !TAI->getWeakRefDirective())
-        O << "\t.globl\t" << Name << "\n";
+        O << "\t.globl\t" << Name << '\n';
       else if (I->hasWeakLinkage())
-        O << TAI->getWeakRefDirective() << Name << "\n";
+        O << TAI->getWeakRefDirective() << Name << '\n';
       else if (!I->hasInternalLinkage())
         assert(0 && "Invalid alias linkage");
 
       if (I->hasHiddenVisibility()) {
         if (const char *Directive = TAI->getHiddenDirective())
-          O << Directive << Name << "\n";
+          O << Directive << Name << '\n';
       } else if (I->hasProtectedVisibility()) {
         if (const char *Directive = TAI->getProtectedDirective())
-          O << Directive << Name << "\n";
+          O << Directive << Name << '\n';
       }
 
-      O << TAI->getSetDirective() << ' ' << Name << ", " << Target << "\n";
+      O << TAI->getSetDirective() << ' ' << Name << ", " << Target << '\n';
 
       // If the aliasee has external weak linkage it can be referenced only by
       // alias itself. In this case it can be not in ExtWeakSymbols list. Emit
       // weak reference in such case.
       if (GV->hasExternalWeakLinkage()) {
         if (TAI->getWeakRefDirective())
-          O << TAI->getWeakRefDirective() << Target << "\n";
+          O << TAI->getWeakRefDirective() << Target << '\n';
         else
-          O << "\t.globl\t" << Target << "\n";
+          O << "\t.globl\t" << Target << '\n';
       }
     }
   }
@@ -192,6 +189,13 @@
                                          E = CMM->begin(); I != E; )
     (*--I)->finishAssembly(O, *this, *TAI);
 
+  // If we don't have any trampolines, then we don't require stack memory
+  // to be executable. Some targets have a directive to declare this.
+  Function* InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline");
+  if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty())
+    if (TAI->getNonexecutableStackDirective())
+      O << TAI->getNonexecutableStackDirective() << '\n';
+
   delete Mang; Mang = 0;
   return false;
 }
@@ -258,7 +262,7 @@
   EmitAlignment(Alignment);
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
     O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
-      << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << " ";
+      << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << ' ';
     WriteTypeSymbolic(O, CP[i].first.getType(), 0) << '\n';
     if (CP[i].first.isMachineConstantPoolEntry())
       EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
@@ -422,7 +426,7 @@
   for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
     O << Directive;
     EmitConstantValueOnly(InitList->getOperand(i));
-    O << "\n";
+    O << '\n';
   }
 }
 
@@ -542,16 +546,27 @@
 /// EOL - Print a newline character to asm stream.  If a comment is present
 /// then it will be printed first.  Comments should not contain '\n'.
 void AsmPrinter::EOL() const {
-  O << "\n";
+  O << '\n';
 }
+
 void AsmPrinter::EOL(const std::string &Comment) const {
-  if (AsmVerbose && !Comment.empty()) {
-    O << "\t"
+  if (VerboseAsm && !Comment.empty()) {
+    O << '\t'
       << TAI->getCommentString()
-      << " "
+      << ' '
       << Comment;
   }
-  O << "\n";
+  O << '\n';
+}
+
+void AsmPrinter::EOL(const char* Comment) const {
+  if (VerboseAsm && *Comment) {
+    O << '\t'
+      << TAI->getCommentString()
+      << ' '
+      << Comment;
+  }
+  O << '\n';
 }
 
 /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
@@ -607,10 +622,10 @@
     PrintHex(Value);
   } else {
     if (TM.getTargetData()->isBigEndian()) {
-      EmitInt32(unsigned(Value >> 32)); O << "\n";
+      EmitInt32(unsigned(Value >> 32)); O << '\n';
       EmitInt32(unsigned(Value));
     } else {
-      EmitInt32(unsigned(Value)); O << "\n";
+      EmitInt32(unsigned(Value)); O << '\n';
       EmitInt32(unsigned(Value >> 32));
     }
   }
@@ -657,13 +672,13 @@
     O << AscizDirective;
   else
     O << TAI->getAsciiDirective();
-  O << "\"";
+  O << '\"';
   for (unsigned i = 0, N = String.size(); i < N; ++i) {
     unsigned char C = String[i];
     printStringChar(O, C);
   }
   if (AscizDirective)
-    O << "\"";
+    O << '\"';
   else
     O << "\\0\"";
 }
@@ -676,7 +691,7 @@
     unsigned char C = Name[i];
     printStringChar(O, C);
   }
-  O << "\"";
+  O << '\"';
 }
 
 
@@ -709,7 +724,7 @@
   unsigned FillValue = TAI->getTextAlignFillValue();
   UseFillExpr &= IsInTextSection && FillValue;
   if (UseFillExpr) O << ",0x" << std::hex << FillValue << std::dec;
-  O << "\n";
+  O << '\n';
 }
 
     
@@ -721,7 +736,7 @@
       O << TAI->getZeroDirective() << NumZeros;
       if (TAI->getZeroDirectiveSuffix())
         O << TAI->getZeroDirectiveSuffix();
-      O << "\n";
+      O << '\n';
     } else {
       for (; NumZeros; --NumZeros)
         O << TAI->getData8bitsDirective() << "0\n";
@@ -733,7 +748,7 @@
 // constants valid in constant expressions can occur here.
 void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
   if (CV->isNullValue() || isa<UndefValue>(CV))
-    O << "0";
+    O << '0';
   else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
     O << CI->getZExtValue();
   } else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
@@ -761,7 +776,7 @@
       if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), &idxVec[0],
                                                 idxVec.size())) {
         if (Offset)
-          O << "(";
+          O << '(';
         EmitConstantValueOnly(ptrVal);
         if (Offset > 0)
           O << ") + " << Offset;
@@ -816,9 +831,9 @@
     case Instruction::And:
     case Instruction::Or:
     case Instruction::Xor:
-      O << "(";
+      O << '(';
       EmitConstantValueOnly(CE->getOperand(0));
-      O << ")";
+      O << ')';
       switch (Opcode) {
       case Instruction::Add:
        O << " + ";
@@ -838,9 +853,9 @@
       default:
        break;
       }
-      O << "(";
+      O << '(';
       EmitConstantValueOnly(CE->getOperand(1));
-      O << ")";
+      O << ')';
       break;
     default:
       assert(0 && "Unsupported operator!");
@@ -857,13 +872,13 @@
                            unsigned LastElt) {
   assert(CVA->isString() && "Array is not string compatible!");
 
-  O << "\"";
+  O << '\"';
   for (unsigned i = 0; i != LastElt; ++i) {
     unsigned char C =
         (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getZExtValue();
     printStringChar(O, C);
   }
-  O << "\"";
+  O << '\"';
 }
 
 /// EmitString - Emit a zero-byte-terminated string constant.
@@ -878,15 +893,13 @@
     O << TAI->getAsciiDirective();
     printAsCString(O, CVA, NumElts);
   }
-  O << "\n";
+  O << '\n';
 }
 
 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
-/// If Packed is false, pad to the ABI size.
-void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) {
+void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
   const TargetData *TD = TM.getTargetData();
-  unsigned Size = Packed ?
-    TD->getTypeStoreSize(CV->getType()) : TD->getABITypeSize(CV->getType());
+  unsigned Size = TD->getABITypeSize(CV->getType());
 
   if (CV->isNullValue() || isa<UndefValue>(CV)) {
     EmitZeros(Size);
@@ -896,7 +909,7 @@
       EmitString(CVA);
     } else { // Not a string.  Print the values in successive locations
       for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
-        EmitGlobalConstant(CVA->getOperand(i), false);
+        EmitGlobalConstant(CVA->getOperand(i));
     }
     return;
   } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
@@ -907,13 +920,13 @@
       const Constant* field = CVS->getOperand(i);
 
       // Check if padding is needed and insert one or more 0s.
-      uint64_t fieldSize = TD->getTypeStoreSize(field->getType());
+      uint64_t fieldSize = TD->getABITypeSize(field->getType());
       uint64_t padSize = ((i == e-1 ? Size : cvsLayout->getElementOffset(i+1))
                           - cvsLayout->getElementOffset(i)) - fieldSize;
       sizeSoFar += fieldSize + padSize;
 
-      // Now print the actual field value without ABI size padding.
-      EmitGlobalConstant(field, true);
+      // Now print the actual field value.
+      EmitGlobalConstant(field);
 
       // Insert padding - this may include padding to increase the size of the
       // current field up to the ABI size (if the struct is not packed) as well
@@ -930,29 +943,29 @@
       double Val = CFP->getValueAPF().convertToDouble();  // for comment only
       uint64_t i = CFP->getValueAPF().convertToAPInt().getZExtValue();
       if (TAI->getData64bitsDirective())
-        O << TAI->getData64bitsDirective() << i << "\t"
-          << TAI->getCommentString() << " double value: " << Val << "\n";
+        O << TAI->getData64bitsDirective() << i << '\t'
+          << TAI->getCommentString() << " double value: " << Val << '\n';
       else if (TD->isBigEndian()) {
         O << TAI->getData32bitsDirective() << unsigned(i >> 32)
-          << "\t" << TAI->getCommentString()
-          << " double most significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " double most significant word " << Val << '\n';
         O << TAI->getData32bitsDirective() << unsigned(i)
-          << "\t" << TAI->getCommentString()
-          << " double least significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " double least significant word " << Val << '\n';
       } else {
         O << TAI->getData32bitsDirective() << unsigned(i)
-          << "\t" << TAI->getCommentString()
-          << " double least significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " double least significant word " << Val << '\n';
         O << TAI->getData32bitsDirective() << unsigned(i >> 32)
-          << "\t" << TAI->getCommentString()
-          << " double most significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " double most significant word " << Val << '\n';
       }
       return;
     } else if (CFP->getType() == Type::FloatTy) {
       float Val = CFP->getValueAPF().convertToFloat();  // for comment only
       O << TAI->getData32bitsDirective()
         << CFP->getValueAPF().convertToAPInt().getZExtValue()
-        << "\t" << TAI->getCommentString() << " float " << Val << "\n";
+        << '\t' << TAI->getCommentString() << " float " << Val << '\n';
       return;
     } else if (CFP->getType() == Type::X86_FP80Ty) {
       // all long double variants are printed as hex
@@ -963,37 +976,37 @@
       DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven);
       if (TD->isBigEndian()) {
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double most significant halfword of ~"
-          << DoubleVal.convertToDouble() << "\n";
+          << DoubleVal.convertToDouble() << '\n';
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next halfword\n";
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 16)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next halfword\n";
         O << TAI->getData16bitsDirective() << uint16_t(p[0])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next halfword\n";
         O << TAI->getData16bitsDirective() << uint16_t(p[1])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double least significant halfword\n";
        } else {
         O << TAI->getData16bitsDirective() << uint16_t(p[1])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double least significant halfword of ~"
-          << DoubleVal.convertToDouble() << "\n";
+          << DoubleVal.convertToDouble() << '\n';
         O << TAI->getData16bitsDirective() << uint16_t(p[0])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next halfword\n";
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 16)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next halfword\n";
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next halfword\n";
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double most significant halfword\n";
       }
       EmitZeros(Size - TD->getTypeStoreSize(Type::X86_FP80Ty));
@@ -1005,29 +1018,29 @@
       const uint64_t *p = api.getRawData();
       if (TD->isBigEndian()) {
         O << TAI->getData32bitsDirective() << uint32_t(p[0] >> 32)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double most significant word\n";
         O << TAI->getData32bitsDirective() << uint32_t(p[0])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next word\n";
         O << TAI->getData32bitsDirective() << uint32_t(p[1] >> 32)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next word\n";
         O << TAI->getData32bitsDirective() << uint32_t(p[1])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double least significant word\n";
        } else {
         O << TAI->getData32bitsDirective() << uint32_t(p[1])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double least significant word\n";
         O << TAI->getData32bitsDirective() << uint32_t(p[1] >> 32)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next word\n";
         O << TAI->getData32bitsDirective() << uint32_t(p[0])
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double next word\n";
         O << TAI->getData32bitsDirective() << uint32_t(p[0] >> 32)
-          << "\t" << TAI->getCommentString()
+          << '\t' << TAI->getCommentString()
           << " long double most significant word\n";
       }
       return;
@@ -1037,21 +1050,21 @@
       uint64_t Val = CI->getZExtValue();
 
       if (TAI->getData64bitsDirective())
-        O << TAI->getData64bitsDirective() << Val << "\n";
+        O << TAI->getData64bitsDirective() << Val << '\n';
       else if (TD->isBigEndian()) {
         O << TAI->getData32bitsDirective() << unsigned(Val >> 32)
-          << "\t" << TAI->getCommentString()
-          << " Double-word most significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " Double-word most significant word " << Val << '\n';
         O << TAI->getData32bitsDirective() << unsigned(Val)
-          << "\t" << TAI->getCommentString()
-          << " Double-word least significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " Double-word least significant word " << Val << '\n';
       } else {
         O << TAI->getData32bitsDirective() << unsigned(Val)
-          << "\t" << TAI->getCommentString()
-          << " Double-word least significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " Double-word least significant word " << Val << '\n';
         O << TAI->getData32bitsDirective() << unsigned(Val >> 32)
-          << "\t" << TAI->getCommentString()
-          << " Double-word most significant word " << Val << "\n";
+          << '\t' << TAI->getCommentString()
+          << " Double-word most significant word " << Val << '\n';
       }
       return;
     }
@@ -1059,7 +1072,7 @@
     const VectorType *PTy = CP->getType();
     
     for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I)
-      EmitGlobalConstant(CP->getOperand(I), false);
+      EmitGlobalConstant(CP->getOperand(I));
     
     return;
   }
@@ -1067,7 +1080,12 @@
   const Type *type = CV->getType();
   printDataDirective(type);
   EmitConstantValueOnly(CV);
-  O << "\n";
+  if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
+    O << "\t\t\t"
+      << TAI->getCommentString()
+      << " 0x" << CI->getValue().toStringUnsigned(16);
+  }
+  O << '\n';
 }
 
 void
@@ -1131,7 +1149,7 @@
   // If this asmstr is empty, just print the #APP/#NOAPP markers.
   // These are useful to see where empty asm's wound up.
   if (AsmStr[0] == 0) {
-    O << TAI->getInlineAsmStart() << "\n\t" << TAI->getInlineAsmEnd() << "\n";
+    O << TAI->getInlineAsmStart() << "\n\t" << TAI->getInlineAsmEnd() << '\n';
     return;
   }
   
@@ -1158,7 +1176,7 @@
     }
     case '\n':
       ++LastEmitted;   // Consume newline character.
-      O << "\n";       // Indent code with newline.
+      O << '\n';       // Indent code with newline.
       break;
     case '$': {
       ++LastEmitted;   // Consume '$' character.
@@ -1295,21 +1313,20 @@
     }
     }
   }
-  O << "\n\t" << TAI->getInlineAsmEnd() << "\n";
+  O << "\n\t" << TAI->getInlineAsmEnd() << '\n';
 }
 
 /// printImplicitDef - This method prints the specified machine instruction
 /// that is an implicit def.
 void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
-  O << "\t" << TAI->getCommentString() << " implicit-def: "
-    << TRI->getAsmName(MI->getOperand(0).getReg()) << "\n";
+  O << '\t' << TAI->getCommentString() << " implicit-def: "
+    << TRI->getAsmName(MI->getOperand(0).getReg()) << '\n';
 }
 
 /// printLabel - This method prints a local label used by debug and
 /// exception handling tables.
 void AsmPrinter::printLabel(const MachineInstr *MI) const {
-  O << TAI->getPrivateGlobalPrefix()
-    << "label" << MI->getOperand(0).getImm() << ":\n";
+  printLabel(MI->getOperand(0).getImm());
 }
 
 void AsmPrinter::printLabel(unsigned Id) const {
@@ -1354,7 +1371,7 @@
       EmitAlignment(Log2_32(Align));
   }
 
-  O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << "_"
+  O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << '_'
     << MBB->getNumber();
   if (printColon)
     O << ':';
@@ -1428,3 +1445,10 @@
   }
 }
 
+void AsmPrinter::printSuffixedName(std::string &Name, const char* Suffix) {
+  if (Name[0]=='\"')
+    O << '\"' << TAI->getPrivateGlobalPrefix() << 
+         Name.substr(1, Name.length()-2) << Suffix << '\"';
+  else
+    O << TAI->getPrivateGlobalPrefix() << Name << Suffix;
+}

Modified: llvm/branches/non-call-eh/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/BranchFolding.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/BranchFolding.cpp Sun Jul  6 15:45:41 2008
@@ -38,13 +38,13 @@
 STATISTIC(NumTailMerge , "Number of block tails merged");
 static cl::opt<cl::boolOrDefault> FlagEnableTailMerge("enable-tail-merge", 
                               cl::init(cl::BOU_UNSET), cl::Hidden);
-namespace {
-  // Throttle for huge numbers of predecessors (compile speed problems)
-  cl::opt<unsigned>
-  TailMergeThreshold("tail-merge-threshold", 
-            cl::desc("Max number of predecessors to consider tail merging"),
-            cl::init(100), cl::Hidden);
+// Throttle for huge numbers of predecessors (compile speed problems)
+static cl::opt<unsigned>
+TailMergeThreshold("tail-merge-threshold", 
+          cl::desc("Max number of predecessors to consider tail merging"),
+          cl::init(100), cl::Hidden);
 
+namespace {
   struct VISIBILITY_HIDDEN BranchFolder : public MachineFunctionPass {
     static char ID;
     explicit BranchFolder(bool defaultEnableTailMerge) : 
@@ -71,8 +71,19 @@
                                  MachineBasicBlock *NewDest);
     MachineBasicBlock *SplitMBBAt(MachineBasicBlock &CurMBB,
                                   MachineBasicBlock::iterator BBI1);
+    unsigned ComputeSameTails(unsigned CurHash, unsigned minCommonTailLength);
+    void RemoveBlocksWithHash(unsigned CurHash, MachineBasicBlock* SuccBB,
+                                                MachineBasicBlock* PredBB);
+    unsigned CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB,
+                                       unsigned maxCommonTailLength);
+
+    typedef std::pair<unsigned,MachineBasicBlock*> MergePotentialsElt;
+    typedef std::vector<MergePotentialsElt>::iterator MPIterator;
+    std::vector<MergePotentialsElt> MergePotentials;
+
+    typedef std::pair<MPIterator, MachineBasicBlock::iterator> SameTailElt;
+    std::vector<SameTailElt> SameTails;
 
-    std::vector<std::pair<unsigned,MachineBasicBlock*> > MergePotentials;
     const TargetRegisterInfo *RegInfo;
     RegScavenger *RS;
     // Branch optzn.
@@ -103,12 +114,12 @@
   while (!MBB->succ_empty())
     MBB->removeSuccessor(MBB->succ_end()-1);
   
-  // If there is DWARF info to active, check to see if there are any LABEL
+  // If there is DWARF info to active, check to see if there are any DBG_LABEL
   // records in the basic block.  If so, unregister them from MachineModuleInfo.
   if (MMI && !MBB->empty()) {
     for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
          I != E; ++I) {
-      if ((unsigned)I->getOpcode() == TargetInstrInfo::LABEL) {
+      if ((unsigned)I->getOpcode() == TargetInstrInfo::DBG_LABEL) {
         // The label ID # is always operand #0, an immediate.
         MMI->InvalidateLabel(I->getOperand(0).getImm());
       }
@@ -218,8 +229,7 @@
     // If a jump table was merge with another one, walk the function rewriting
     // references to jump tables to reference the new JT ID's.  Keep track of
     // whether we see a jump table idx, if not, we can delete the JT.
-    std::vector<bool> JTIsLive;
-    JTIsLive.resize(JTs.size());
+    BitVector JTIsLive(JTs.size());
     for (MachineFunction::iterator BB = MF.begin(), E = MF.end();
          BB != E; ++BB) {
       for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end();
@@ -231,7 +241,7 @@
           Op.setIndex(NewIdx);
 
           // Remember that this JT is live.
-          JTIsLive[NewIdx] = true;
+          JTIsLive.set(NewIdx);
         }
     }
    
@@ -239,7 +249,7 @@
     // indirect jump was unreachable (and thus deleted) or because the jump
     // table was merged with some other one.
     for (unsigned i = 0, e = JTIsLive.size(); i != e; ++i)
-      if (!JTIsLive[i]) {
+      if (!JTIsLive.test(i)) {
         JTI->RemoveJumpTable(i);
         EverMadeChange = true;
       }
@@ -371,11 +381,7 @@
   CurMBB.getParent()->getBasicBlockList().insert(++MBBI, NewMBB);
 
   // Move all the successors of this block to the specified block.
-  while (!CurMBB.succ_empty()) {
-    MachineBasicBlock *S = *(CurMBB.succ_end()-1);
-    NewMBB->addSuccessor(S);
-    CurMBB.removeSuccessor(S);
-  }
+  NewMBB->transferSuccessors(&CurMBB);
  
   // Add an edge from CurMBB to NewMBB for the fall-through.
   CurMBB.addSuccessor(NewMBB);
@@ -415,42 +421,6 @@
   return Time;
 }
 
-/// ShouldSplitFirstBlock - We need to either split MBB1 at MBB1I or MBB2 at
-/// MBB2I and then insert an unconditional branch in the other block.  Determine
-/// which is the best to split
-static bool ShouldSplitFirstBlock(MachineBasicBlock *MBB1,
-                                  MachineBasicBlock::iterator MBB1I,
-                                  MachineBasicBlock *MBB2,
-                                  MachineBasicBlock::iterator MBB2I,
-                                  MachineBasicBlock *PredBB) {
-  // If one block is the entry block, split the other one; we can't generate
-  // a branch to the entry block, as its label is not emitted.
-  MachineBasicBlock *Entry = MBB1->getParent()->begin();
-  if (MBB1 == Entry)
-    return false;
-  if (MBB2 == Entry)
-    return true;
-
-  // If one block falls through into the common successor, choose that
-  // one to split; it is one instruction less to do that.
-  if (PredBB) {
-    if (MBB1 == PredBB)
-      return true;
-    else if (MBB2 == PredBB)
-      return false;
-  }
-  // TODO: if we had some notion of which block was hotter, we could split
-  // the hot block, so it is the fall-through.  Since we don't have profile info
-  // make a decision based on which will hurt most to split.
-  unsigned MBB1Time = EstimateRuntime(MBB1->begin(), MBB1I);
-  unsigned MBB2Time = EstimateRuntime(MBB2->begin(), MBB2I);
-  
-  // If the MBB1 prefix takes "less time" to run than the MBB2 prefix, split the
-  // MBB1 block so it falls through.  This will penalize the MBB2 path, but will
-  // have a lower overall impact on the program execution.
-  return MBB1Time < MBB2Time;
-}
-
 // CurMBB needs to add an unconditional branch to SuccMBB (we removed these
 // branches temporarily for tail merging).  In the case where CurMBB ends
 // with a conditional branch to the next block, optimize by reversing the
@@ -465,7 +435,7 @@
   if (I != MF->end() &&
       !TII->AnalyzeBranch(*CurMBB, TBB, FBB, Cond)) {
     MachineBasicBlock *NextBB = I;
-    if (TBB == NextBB && Cond.size() && !FBB) {
+    if (TBB == NextBB && !Cond.empty() && !FBB) {
       if (!TII->ReverseBranchCondition(Cond)) {
         TII->RemoveBranch(*CurMBB);
         TII->InsertBranch(*CurMBB, SuccBB, NULL, Cond);
@@ -496,6 +466,119 @@
     }
 }
 
+/// ComputeSameTails - Look through all the blocks in MergePotentials that have
+/// hash CurHash (guaranteed to match the last element).   Build the vector 
+/// SameTails of all those that have the (same) largest number of instructions
+/// in common of any pair of these blocks.  SameTails entries contain an
+/// iterator into MergePotentials (from which the MachineBasicBlock can be 
+/// found) and a MachineBasicBlock::iterator into that MBB indicating the 
+/// instruction where the matching code sequence begins.
+/// Order of elements in SameTails is the reverse of the order in which
+/// those blocks appear in MergePotentials (where they are not necessarily
+/// consecutive).
+unsigned BranchFolder::ComputeSameTails(unsigned CurHash, 
+                                        unsigned minCommonTailLength) {
+  unsigned maxCommonTailLength = 0U;
+  SameTails.clear();
+  MachineBasicBlock::iterator TrialBBI1, TrialBBI2;
+  MPIterator HighestMPIter = prior(MergePotentials.end());
+  for (MPIterator CurMPIter = prior(MergePotentials.end()),
+                  B = MergePotentials.begin(); 
+       CurMPIter!=B && CurMPIter->first==CurHash;
+       --CurMPIter) {
+    for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) {
+      unsigned CommonTailLen = ComputeCommonTailLength(
+                                        CurMPIter->second,
+                                        I->second,
+                                        TrialBBI1, TrialBBI2);
+      // If we will have to split a block, there should be at least
+      // minCommonTailLength instructions in common; if not, at worst
+      // we will be replacing a fallthrough into the common tail with a
+      // branch, which at worst breaks even with falling through into
+      // the duplicated common tail, so 1 instruction in common is enough.
+      // We will always pick a block we do not have to split as the common
+      // tail if there is one.
+      // (Empty blocks will get forwarded and need not be considered.)
+      if (CommonTailLen >= minCommonTailLength ||
+          (CommonTailLen > 0 &&
+           (TrialBBI1==CurMPIter->second->begin() ||
+            TrialBBI2==I->second->begin()))) {
+        if (CommonTailLen > maxCommonTailLength) {
+          SameTails.clear();
+          maxCommonTailLength = CommonTailLen;
+          HighestMPIter = CurMPIter;
+          SameTails.push_back(std::make_pair(CurMPIter, TrialBBI1));
+        }
+        if (HighestMPIter == CurMPIter &&
+            CommonTailLen == maxCommonTailLength)
+          SameTails.push_back(std::make_pair(I, TrialBBI2));
+      }
+      if (I==B)
+        break;
+    }
+  }
+  return maxCommonTailLength;
+}
+
+/// RemoveBlocksWithHash - Remove all blocks with hash CurHash from
+/// MergePotentials, restoring branches at ends of blocks as appropriate.
+void BranchFolder::RemoveBlocksWithHash(unsigned CurHash, 
+                                        MachineBasicBlock* SuccBB,
+                                        MachineBasicBlock* PredBB) {
+  MPIterator CurMPIter, B;
+  for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin(); 
+       CurMPIter->first==CurHash;
+       --CurMPIter) {
+    // Put the unconditional branch back, if we need one.
+    MachineBasicBlock *CurMBB = CurMPIter->second;
+    if (SuccBB && CurMBB != PredBB)
+      FixTail(CurMBB, SuccBB, TII);
+    if (CurMPIter==B)
+      break;
+  }
+  if (CurMPIter->first!=CurHash)
+    CurMPIter++;
+  MergePotentials.erase(CurMPIter, MergePotentials.end());
+}
+
+/// CreateCommonTailOnlyBlock - None of the blocks to be tail-merged consist
+/// only of the common tail.  Create a block that does by splitting one.
+unsigned BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB,
+                                             unsigned maxCommonTailLength) {
+  unsigned i, commonTailIndex;
+  unsigned TimeEstimate = ~0U;
+  for (i=0, commonTailIndex=0; i<SameTails.size(); i++) {
+    // Use PredBB if possible; that doesn't require a new branch.
+    if (SameTails[i].first->second==PredBB) {
+      commonTailIndex = i;
+      break;
+    }
+    // Otherwise, make a (fairly bogus) choice based on estimate of
+    // how long it will take the various blocks to execute.
+    unsigned t = EstimateRuntime(SameTails[i].first->second->begin(), 
+                                 SameTails[i].second);
+    if (t<=TimeEstimate) {
+      TimeEstimate = t;
+      commonTailIndex = i;
+    }
+  }
+
+  MachineBasicBlock::iterator BBI = SameTails[commonTailIndex].second;
+  MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second;
+
+  DOUT << "\nSplitting " << MBB->getNumber() << ", size " << 
+          maxCommonTailLength;
+
+  MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI);
+  SameTails[commonTailIndex].first->second = newMBB;
+  SameTails[commonTailIndex].second = newMBB->begin();
+  // If we split PredBB, newMBB is the new predecessor.
+  if (PredBB==MBB)
+    PredBB = newMBB;
+
+  return commonTailIndex;
+}
+
 // See if any of the blocks in MergePotentials (which all have a common single
 // successor, or all have no successor) can be tail-merged.  If there is a
 // successor, any blocks in MergePotentials that are not tail-merged and
@@ -512,124 +595,66 @@
   unsigned minCommonTailLength = (SuccBB ? 1 : 2) + 1;
   MadeChange = false;
   
+  DOUT << "\nTryMergeBlocks " << MergePotentials.size();
+
   // Sort by hash value so that blocks with identical end sequences sort
   // together.
-  std::stable_sort(MergePotentials.begin(), MergePotentials.end(), MergeCompare);
+  std::stable_sort(MergePotentials.begin(), MergePotentials.end(),MergeCompare);
 
   // Walk through equivalence sets looking for actual exact matches.
   while (MergePotentials.size() > 1) {
-    unsigned CurHash  = (MergePotentials.end()-1)->first;
-    unsigned PrevHash = (MergePotentials.end()-2)->first;
-    MachineBasicBlock *CurMBB = (MergePotentials.end()-1)->second;
+    unsigned CurHash  = prior(MergePotentials.end())->first;
     
-    // If there is nothing that matches the hash of the current basic block,
-    // give up.
-    if (CurHash != PrevHash) {
-      if (SuccBB && CurMBB != PredBB)
-        FixTail(CurMBB, SuccBB, TII);
-      MergePotentials.pop_back();
-      continue;
-    }
-    
-    // Look through all the pairs of blocks that have the same hash as this
-    // one, and find the pair that has the largest number of instructions in
-    // common.
-    // Since instructions may get combined later (e.g. single stores into
-    // store multiple) this measure is not particularly accurate.
-    MachineBasicBlock::iterator BBI1, BBI2;
-    
-    unsigned FoundI = ~0U, FoundJ = ~0U;
-    unsigned maxCommonTailLength = 0U;
-    for (int i = MergePotentials.size()-1;
-         i != -1 && MergePotentials[i].first == CurHash; --i) {
-      for (int j = i-1; 
-           j != -1 && MergePotentials[j].first == CurHash; --j) {
-        MachineBasicBlock::iterator TrialBBI1, TrialBBI2;
-        unsigned CommonTailLen = ComputeCommonTailLength(
-                                                MergePotentials[i].second,
-                                                MergePotentials[j].second,
-                                                TrialBBI1, TrialBBI2);
-        if (CommonTailLen >= minCommonTailLength &&
-            CommonTailLen > maxCommonTailLength) {
-          FoundI = i;
-          FoundJ = j;
-          maxCommonTailLength = CommonTailLen;
-          BBI1 = TrialBBI1;
-          BBI2 = TrialBBI2;
-        }
-      }
-    }
+    // Build SameTails, identifying the set of blocks with this hash code
+    // and with the maximum number of instructions in common.
+    unsigned maxCommonTailLength = ComputeSameTails(CurHash, 
+                                                    minCommonTailLength);
 
     // If we didn't find any pair that has at least minCommonTailLength 
-    // instructions in common, bail out.  All entries with this
-    // hash code can go away now.
-    if (FoundI == ~0U) {
-      for (int i = MergePotentials.size()-1;
-           i != -1 && MergePotentials[i].first == CurHash; --i) {
-        // Put the unconditional branch back, if we need one.
-        CurMBB = MergePotentials[i].second;
-        if (SuccBB && CurMBB != PredBB)
-          FixTail(CurMBB, SuccBB, TII);
-        MergePotentials.pop_back();
-      }
+    // instructions in common, remove all blocks with this hash code and retry.
+    if (SameTails.empty()) {
+      RemoveBlocksWithHash(CurHash, SuccBB, PredBB);
       continue;
     }
 
-    // Otherwise, move the block(s) to the right position(s).  So that
-    // BBI1/2 will be valid, the last must be I and the next-to-last J.
-    if (FoundI != MergePotentials.size()-1)
-      std::swap(MergePotentials[FoundI], *(MergePotentials.end()-1));
-    if (FoundJ != MergePotentials.size()-2)
-      std::swap(MergePotentials[FoundJ], *(MergePotentials.end()-2));
-
-    CurMBB = (MergePotentials.end()-1)->second;
-    MachineBasicBlock *MBB2 = (MergePotentials.end()-2)->second;
-
-    // If neither block is the entire common tail, split the tail of one block
-    // to make it redundant with the other tail.  Also, we cannot jump to the
-    // entry block, so if one block is the entry block, split the other one.
-    MachineBasicBlock *Entry = CurMBB->getParent()->begin();
-    if (CurMBB->begin() == BBI1 && CurMBB != Entry)
-      ;   // CurMBB is common tail
-    else if (MBB2->begin() == BBI2 && MBB2 != Entry)
-      ;   // MBB2 is common tail
-    else {
-      if (0) { // Enable this to disable partial tail merges.
-        MergePotentials.pop_back();
-        continue;
-      }
-      
-      MachineBasicBlock::iterator TrialBBI1, TrialBBI2;
-      unsigned CommonTailLen = ComputeCommonTailLength(CurMBB, MBB2,
-                                                       TrialBBI1, TrialBBI2);
-      if (CommonTailLen < minCommonTailLength)
-        continue;
-
-      // Decide whether we want to split CurMBB or MBB2.
-      if (ShouldSplitFirstBlock(CurMBB, BBI1, MBB2, BBI2, PredBB)) {
-        CurMBB = SplitMBBAt(*CurMBB, BBI1);
-        BBI1 = CurMBB->begin();
-        MergePotentials.back().second = CurMBB;
-      } else {
-        MBB2 = SplitMBBAt(*MBB2, BBI2);
-        BBI2 = MBB2->begin();
-        (MergePotentials.end()-2)->second = MBB2;
+    // If one of the blocks is the entire common tail (and not the entry
+    // block, which we can't jump to), we can treat all blocks with this same
+    // tail at once.  Use PredBB if that is one of the possibilities, as that
+    // will not introduce any extra branches.
+    MachineBasicBlock *EntryBB = MergePotentials.begin()->second->
+                                getParent()->begin();
+    unsigned int commonTailIndex, i;
+    for (commonTailIndex=SameTails.size(), i=0; i<SameTails.size(); i++) {
+      MachineBasicBlock *MBB = SameTails[i].first->second;
+      if (MBB->begin() == SameTails[i].second && MBB != EntryBB) {
+        commonTailIndex = i;
+        if (MBB==PredBB)
+          break;
       }
     }
-    
-    if (MBB2->begin() == BBI2 && MBB2 != Entry) {
-      // Hack the end off CurMBB, making it jump to MBBI@ instead.
-      ReplaceTailWithBranchTo(BBI1, MBB2);
-      // This modifies CurMBB, so remove it from the worklist.
-      MergePotentials.pop_back();
-    } else {
-      assert(CurMBB->begin() == BBI1 && CurMBB != Entry && 
-             "Didn't split block correctly?");
-      // Hack the end off MBB2, making it jump to CurMBB instead.
-      ReplaceTailWithBranchTo(BBI2, CurMBB);
-      // This modifies MBB2, so remove it from the worklist.
-      MergePotentials.erase(MergePotentials.end()-2);
+
+    if (commonTailIndex==SameTails.size()) {
+      // None of the blocks consist entirely of the common tail.
+      // Split a block so that one does.
+      commonTailIndex = CreateCommonTailOnlyBlock(PredBB,  maxCommonTailLength);
     }
+
+    MachineBasicBlock *MBB = SameTails[commonTailIndex].first->second;
+    // MBB is common tail.  Adjust all other BB's to jump to this one.
+    // Traversal must be forwards so erases work.
+    DOUT << "\nUsing common tail " << MBB->getNumber() << " for ";
+    for (unsigned int i=0; i<SameTails.size(); ++i) {
+      if (commonTailIndex==i)
+        continue;
+      DOUT << SameTails[i].first->second->getNumber() << ",";
+      // Hack the end off BB i, making it jump to BB commonTailIndex instead.
+      ReplaceTailWithBranchTo(SameTails[i].second, MBB);
+      // BB i is no longer a predecessor of SuccBB; remove it from the worklist.
+      MergePotentials.erase(SameTails[i].first);
+    }
+    DOUT << "\n";
+    // We leave commonTailIndex in the worklist in case there are other blocks
+    // that match it with a smaller number of instructions.
     MadeChange = true;
   }
   return MadeChange;
@@ -648,7 +673,8 @@
       MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I));
   }
   // See if we can do any tail merging on those.
-  if (MergePotentials.size() < TailMergeThreshold)
+  if (MergePotentials.size() < TailMergeThreshold &&
+      MergePotentials.size() >= 2)
     MadeChange |= TryMergeBlocks(NULL, NULL);
 
   // Look at blocks (IBB) with multiple predecessors (PBB).
@@ -671,8 +697,7 @@
   // transformations.)
 
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
-    if (!I->succ_empty() && I->pred_size() >= 2 && 
-         I->pred_size() < TailMergeThreshold) {
+    if (I->pred_size() >= 2 && I->pred_size() < TailMergeThreshold) {
       MachineBasicBlock *IBB = I;
       MachineBasicBlock *PredBB = prior(I);
       MergePotentials.clear();
@@ -689,7 +714,7 @@
           // Failing case:  IBB is the target of a cbr, and
           // we cannot reverse the branch.
           std::vector<MachineOperand> NewCond(Cond);
-          if (Cond.size() && TBB==IBB) {
+          if (!Cond.empty() && TBB==IBB) {
             if (TII->ReverseBranchCondition(NewCond))
               continue;
             // This is the QBB case described above
@@ -719,9 +744,9 @@
             }
           }
           // Remove the unconditional branch at the end, if any.
-          if (TBB && (Cond.size()==0 || FBB)) {
+          if (TBB && (Cond.empty() || FBB)) {
             TII->RemoveBranch(*PBB);
-            if (Cond.size())
+            if (!Cond.empty())
               // reinsert conditional branch only, for now
               TII->InsertBranch(*PBB, (TBB==IBB) ? FBB : TBB, 0, NewCond);
           }
@@ -731,12 +756,11 @@
     if (MergePotentials.size() >= 2)
       MadeChange |= TryMergeBlocks(I, PredBB);
     // Reinsert an unconditional branch if needed.
-    // The 1 below can be either an original single predecessor, or a result
-    // of removing blocks in TryMergeBlocks.
+    // The 1 below can occur as a result of removing blocks in TryMergeBlocks.
     PredBB = prior(I);      // this may have been changed in TryMergeBlocks
     if (MergePotentials.size()==1 && 
-        (MergePotentials.begin())->second != PredBB)
-      FixTail((MergePotentials.begin())->second, I, TII);
+        MergePotentials.begin()->second != PredBB)
+      FixTail(MergePotentials.begin()->second, I, TII);
     }
   }
   return MadeChange;
@@ -776,7 +800,8 @@
 ///
 bool BranchFolder::CanFallThrough(MachineBasicBlock *CurBB,
                                   bool BranchUnAnalyzable,
-                                  MachineBasicBlock *TBB, MachineBasicBlock *FBB,
+                                  MachineBasicBlock *TBB, 
+                                  MachineBasicBlock *FBB,
                                   const std::vector<MachineOperand> &Cond) {
   MachineFunction::iterator Fallthrough = CurBB;
   ++Fallthrough;

Modified: llvm/branches/non-call-eh/lib/CodeGen/Collector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/Collector.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/Collector.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/Collector.cpp Sun Jul  6 15:45:41 2008
@@ -178,8 +178,8 @@
   SmallPtrSet<AllocaInst*,16> InitedRoots;
   for (; !CouldBecomeSafePoint(IP); ++IP)
     if (StoreInst *SI = dyn_cast<StoreInst>(IP))
-      if (AllocaInst *AI = dyn_cast<AllocaInst>(
-            IntrinsicInst::StripPointerCasts(SI->getOperand(1))))
+      if (AllocaInst *AI =
+          dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
         InitedRoots.insert(AI);
   
   // Add root initializers.
@@ -294,7 +294,7 @@
             // Initialize the GC root, but do not delete the intrinsic. The
             // backend needs the intrinsic to flag the stack slot.
             Roots.push_back(cast<AllocaInst>(
-              IntrinsicInst::StripPointerCasts(CI->getOperand(1))));
+                              CI->getOperand(1)->stripPointerCasts()));
           }
           break;
         default:
@@ -337,7 +337,7 @@
 unsigned MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB, 
                                      MachineBasicBlock::iterator MI) const {
   unsigned Label = MMI->NextLabelID();
-  BuildMI(MBB, MI, TII->get(TargetInstrInfo::LABEL)).addImm(Label).addImm(2);
+  BuildMI(MBB, MI, TII->get(TargetInstrInfo::GC_LABEL)).addImm(Label);
   return Label;
 }
 

Modified: llvm/branches/non-call-eh/lib/CodeGen/CollectorMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/CollectorMetadata.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/CollectorMetadata.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/CollectorMetadata.cpp Sun Jul  6 15:45:41 2008
@@ -51,11 +51,11 @@
     bool doFinalization(Module &M);
   };
   
-  RegisterPass<CollectorModuleMetadata>
-  X("collector-metadata", "Create Garbage Collector Module Metadata");
-  
 }
 
+static RegisterPass<CollectorModuleMetadata>
+X("collector-metadata", "Create Garbage Collector Module Metadata");
+
 // -----------------------------------------------------------------------------
 
 CollectorMetadata::CollectorMetadata(const Function &F, Collector &C)
@@ -112,10 +112,7 @@
 
 void CollectorModuleMetadata::clear() {
   Map.clear();
-  
-  // TODO: StringMap should provide a clear method.
-  while (!NameMap.empty())
-    NameMap.erase(NameMap.begin());
+  NameMap.clear();
   
   for (iterator I = begin(), E = end(); I != E; ++I)
     delete *I;

Modified: llvm/branches/non-call-eh/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/DwarfWriter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/DwarfWriter.cpp Sun Jul  6 15:45:41 2008
@@ -140,7 +140,7 @@
 
   /// Data - Raw data bytes for abbreviation.
   ///
-  std::vector<DIEAbbrevData> Data;
+  SmallVector<DIEAbbrevData, 8> Data;
 
 public:
 
@@ -155,7 +155,7 @@
   unsigned getTag()                           const { return Tag; }
   unsigned getNumber()                        const { return Number; }
   unsigned getChildrenFlag()                  const { return ChildrenFlag; }
-  const std::vector<DIEAbbrevData> &getData() const { return Data; }
+  const SmallVector<DIEAbbrevData, 8> &getData() const { return Data; }
   void setTag(unsigned T)                           { Tag = T; }
   void setChildrenFlag(unsigned CF)                 { ChildrenFlag = CF; }
   void setNumber(unsigned N)                        { Number = N; }
@@ -219,7 +219,7 @@
   
   /// Attributes values.
   ///
-  std::vector<DIEValue *> Values;
+  SmallVector<DIEValue*, 32> Values;
   
 public:
   explicit DIE(unsigned Tag)
@@ -240,7 +240,7 @@
   unsigned getOffset()                       const { return Offset; }
   unsigned getSize()                         const { return Size; }
   const std::vector<DIE *> &getChildren()    const { return Children; }
-  std::vector<DIEValue *> &getValues()       { return Values; }
+  SmallVector<DIEValue*, 32> &getValues()       { return Values; }
   void setTag(unsigned Tag)                  { Abbrev.setTag(Tag); }
   void setOffset(unsigned O)                 { Offset = O; }
   void setSize(unsigned S)                   { Size = S; }
@@ -296,6 +296,7 @@
     isString,
     isLabel,
     isAsIsLabel,
+    isSectionOffset,
     isDelta,
     isEntry,
     isBlock
@@ -505,6 +506,56 @@
 };
 
 //===----------------------------------------------------------------------===//
+/// DIESectionOffset - A section offset DIE.
+//
+class DIESectionOffset : public DIEValue {
+public:
+  const DWLabel Label;
+  const DWLabel Section;
+  bool IsEH : 1;
+  bool UseSet : 1;
+  
+  DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec,
+                   bool isEH = false, bool useSet = true)
+  : DIEValue(isSectionOffset), Label(Lab), Section(Sec),
+                               IsEH(isEH), UseSet(useSet) {}
+
+  // Implement isa/cast/dyncast.
+  static bool classof(const DIESectionOffset *)  { return true; }
+  static bool classof(const DIEValue *D) { return D->Type == isSectionOffset; }
+  
+  /// EmitValue - Emit section offset.
+  ///
+  virtual void EmitValue(DwarfDebug &DD, unsigned Form);
+  
+  /// SizeOf - Determine size of section offset value in bytes.
+  ///
+  virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
+  
+  /// Profile - Used to gather unique data for the value folding set.
+  ///
+  static void Profile(FoldingSetNodeID &ID, const DWLabel &Label,
+                                            const DWLabel &Section) {
+    ID.AddInteger(isSectionOffset);
+    Label.Profile(ID);
+    Section.Profile(ID);
+    // IsEH and UseSet are specific to the Label/Section that we will emit
+    // the offset for; so Label/Section are enough for uniqueness.
+  }
+  virtual void Profile(FoldingSetNodeID &ID) { Profile(ID, Label, Section); }
+
+#ifndef NDEBUG
+  virtual void print(std::ostream &O) {
+    O << "Off: ";
+    Label.print(O);
+    O << "-";
+    Section.print(O);
+    O << "-" << IsEH << "-" << UseSet;
+  }
+#endif
+};
+
+//===----------------------------------------------------------------------===//
 /// DIEDelta - A simple label difference DIE.
 /// 
 class DIEDelta : public DIEValue {
@@ -775,7 +826,7 @@
   ///
   AsmPrinter *Asm;
   
-  /// TAI - Target Asm Printer.
+  /// TAI - Target asm information.
   const TargetAsmInfo *TAI;
   
   /// TD - Target data.
@@ -1275,6 +1326,24 @@
     Die->AddValue(Attribute, Form, Value);
   }
       
+  /// AddSectionOffset - Add a section offset label attribute data and value.
+  ///
+  void AddSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
+                        const DWLabel &Label, const DWLabel &Section,
+                        bool isEH = false, bool useSet = true) {
+    FoldingSetNodeID ID;
+    DIESectionOffset::Profile(ID, Label, Section);
+    void *Where;
+    DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
+    if (!Value) {
+      Value = new DIESectionOffset(Label, Section, isEH, useSet);
+      ValuesSet.InsertNode(Value, Where);
+      Values.push_back(Value);
+    }
+  
+    Die->AddValue(Attribute, Form, Value);
+  }
+      
   /// AddDelta - Add a label delta attribute data and value.
   ///
   void AddDelta(DIE *Die, unsigned Attribute, unsigned Form,
@@ -1714,11 +1783,8 @@
   CompileUnit *NewCompileUnit(CompileUnitDesc *UnitDesc, unsigned ID) {
     // Construct debug information entry.
     DIE *Die = new DIE(DW_TAG_compile_unit);
-    if (TAI->isAbsoluteDebugSectionOffsets())
-      AddLabel(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0));
-    else
-      AddDelta(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0),
-               DWLabel("section_line", 0));      
+    AddSectionOffset(Die, DW_AT_stmt_list, DW_FORM_data4,
+              DWLabel("section_line", 0), DWLabel("section_line", 0), false);
     AddString(Die, DW_AT_producer,  DW_FORM_string, UnitDesc->getProducer());
     AddUInt  (Die, DW_AT_language,  DW_FORM_data1,  UnitDesc->getLanguage());
     AddString(Die, DW_AT_name,      DW_FORM_string, UnitDesc->getFileName());
@@ -2009,14 +2075,18 @@
 
     // Emit the code (index) for the abbreviation.
     Asm->EmitULEB128Bytes(AbbrevNumber);
-    Asm->EOL(std::string("Abbrev [" +
-             utostr(AbbrevNumber) +
-             "] 0x" + utohexstr(Die->getOffset()) +
-             ":0x" + utohexstr(Die->getSize()) + " " +
-             TagString(Abbrev->getTag())));
+
+    if (VerboseAsm)
+      Asm->EOL(std::string("Abbrev [" +
+                           utostr(AbbrevNumber) +
+                           "] 0x" + utohexstr(Die->getOffset()) +
+                           ":0x" + utohexstr(Die->getSize()) + " " +
+                           TagString(Abbrev->getTag())));
+    else
+      Asm->EOL();
     
-    std::vector<DIEValue *> &Values = Die->getValues();
-    const std::vector<DIEAbbrevData> &AbbrevData = Abbrev->getData();
+    SmallVector<DIEValue*, 32> &Values = Die->getValues();
+    const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
     
     // Emit the DIE attribute values.
     for (unsigned i = 0, N = Values.size(); i < N; ++i) {
@@ -2073,8 +2143,8 @@
     // Start the size with the size of abbreviation code.
     Offset += Asm->SizeULEB128(AbbrevNumber);
     
-    const std::vector<DIEValue *> &Values = Die->getValues();
-    const std::vector<DIEAbbrevData> &AbbrevData = Abbrev->getData();
+    const SmallVector<DIEValue*, 32> &Values = Die->getValues();
+    const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
 
     // Size the DIE attribute values.
     for (unsigned i = 0, N = Values.size(); i < N; ++i) {
@@ -2230,8 +2300,7 @@
     Asm->EmitInt8(1); Asm->EOL("DW_LNS_fixed_advance_pc arg count");
 
     const UniqueVector<std::string> &Directories = MMI->getDirectories();
-    const UniqueVector<SourceFileInfo>
-      &SourceFiles = MMI->getSourceFiles();
+    const UniqueVector<SourceFileInfo> &SourceFiles = MMI->getSourceFiles();
 
     // Emit directories.
     for (unsigned DirectoryID = 1, NDID = Directories.size();
@@ -2261,8 +2330,11 @@
     for (unsigned j = 0, M = SectionSourceLines.size(); j < M; ++j) {
       // Isolate current sections line info.
       const std::vector<SourceLineInfo> &LineInfos = SectionSourceLines[j];
-      
-      Asm->EOL(std::string("Section ") + SectionMap[j + 1]);
+
+      if (VerboseAsm)
+        Asm->EOL(std::string("Section ") + SectionMap[j + 1]);
+      else
+        Asm->EOL();
 
       // Dwarf assumes we start with first line of first source file.
       unsigned Source = 1;
@@ -2277,10 +2349,13 @@
         unsigned SourceID = LineInfo.getSourceID();
         const SourceFileInfo &SourceFile = SourceFiles[SourceID];
         unsigned DirectoryID = SourceFile.getDirectoryID();
-        Asm->EOL(Directories[DirectoryID]
-          + SourceFile.getName()
-          + ":"
-          + utostr_32(LineInfo.getLine()));
+        if (VerboseAsm)
+          Asm->EOL(Directories[DirectoryID]
+                   + SourceFile.getName()
+                   + ":"
+                   + utostr_32(LineInfo.getLine()));
+        else
+          Asm->EOL();
 
         // Define the line address.
         Asm->EmitInt8(0); Asm->EOL("Extended Op");
@@ -2555,8 +2630,8 @@
   /// ConstructGlobalDIEs - Create DIEs for each of the externally visible
   /// global variables.
   void ConstructGlobalDIEs() {
-    std::vector<GlobalVariableDesc *> GlobalVariables =
-        MMI->getAnchoredDescriptors<GlobalVariableDesc>(*M);
+    std::vector<GlobalVariableDesc *> GlobalVariables;
+    MMI->getAnchoredDescriptors<GlobalVariableDesc>(*M, GlobalVariables);
     
     for (unsigned i = 0, N = GlobalVariables.size(); i < N; ++i) {
       GlobalVariableDesc *GVD = GlobalVariables[i];
@@ -2567,8 +2642,8 @@
   /// ConstructSubprogramDIEs - Create DIEs for each of the externally visible
   /// subprograms.
   void ConstructSubprogramDIEs() {
-    std::vector<SubprogramDesc *> Subprograms =
-        MMI->getAnchoredDescriptors<SubprogramDesc>(*M);
+    std::vector<SubprogramDesc *> Subprograms;
+    MMI->getAnchoredDescriptors<SubprogramDesc>(*M, Subprograms);
     
     for (unsigned i = 0, N = Subprograms.size(); i < N; ++i) {
       SubprogramDesc *SPD = Subprograms[i];
@@ -2796,7 +2871,7 @@
   /// shouldEmitFrameModule - Per-module flag to indicate if frame moves 
   /// should be emitted.
   bool shouldEmitMovesModule;
-  
+
   /// EmitCommonEHFrame - Emit the common eh unwind frame.
   ///
   void EmitCommonEHFrame(const Function *Personality, unsigned Index) {
@@ -2813,7 +2888,7 @@
 
     // Define base labels.
     EmitLabel("eh_frame_common", Index);
-    
+
     // Define the eh frame length.
     EmitDifference("eh_frame_common_end", Index,
                    "eh_frame_common_begin", Index, true);
@@ -2825,50 +2900,50 @@
     Asm->EOL("CIE Identifier Tag");
     Asm->EmitInt8(DW_CIE_VERSION);
     Asm->EOL("CIE Version");
-    
+
     // The personality presence indicates that language specific information
     // will show up in the eh frame.
     Asm->EmitString(Personality ? "zPLR" : "zR");
     Asm->EOL("CIE Augmentation");
-    
+
     // Round out reader.
     Asm->EmitULEB128Bytes(1);
     Asm->EOL("CIE Code Alignment Factor");
     Asm->EmitSLEB128Bytes(stackGrowth);
-    Asm->EOL("CIE Data Alignment Factor");   
+    Asm->EOL("CIE Data Alignment Factor");
     Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
-    Asm->EOL("CIE RA Column");
-    
+    Asm->EOL("CIE Return Address Column");
+
     // If there is a personality, we need to indicate the functions location.
     if (Personality) {
       Asm->EmitULEB128Bytes(7);
       Asm->EOL("Augmentation Size");
 
-      if (TAI->getNeedsIndirectEncoding())
+      if (TAI->getNeedsIndirectEncoding()) {
         Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect);
-      else
+        Asm->EOL("Personality (pcrel sdata4 indirect)");
+      } else {
         Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4);
+        Asm->EOL("Personality (pcrel sdata4)");
+      }
 
-      Asm->EOL("Personality (pcrel sdata4 indirect)");
-      
-      PrintRelDirective(TAI->getShortenEHDataOn64Bit());
+      PrintRelDirective(true);
       O << TAI->getPersonalityPrefix();
       Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
       O << TAI->getPersonalitySuffix();
-      if (!TAI->getShortenEHDataOn64Bit()) {
+      if (strcmp(TAI->getPersonalitySuffix(), "+4 at GOTPCREL"))
         O << "-" << TAI->getPCSymbol();
-      }
       Asm->EOL("Personality");
 
-      Asm->EmitULEB128Bytes(DW_EH_PE_pcrel);
-      Asm->EOL("LSDA Encoding (pcrel)");
-      Asm->EmitULEB128Bytes(DW_EH_PE_pcrel);
-      Asm->EOL("FDE Encoding (pcrel)");
+      Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4);
+      Asm->EOL("LSDA Encoding (pcrel sdata4)");
+      Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4);
+      Asm->EOL("FDE Encoding (pcrel sdata4)");
    } else {
       Asm->EmitULEB128Bytes(1);
       Asm->EOL("Augmentation Size");
-      Asm->EmitULEB128Bytes(DW_EH_PE_pcrel);
-      Asm->EOL("FDE Encoding (pcrel)");
+      Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4);
+      Asm->EOL("FDE Encoding (pcrel sdata4)");
     }
 
     // Indicate locations of general callee saved registers in frame.
@@ -2876,12 +2951,16 @@
     RI->getInitialFrameState(Moves);
     EmitFrameMoves(NULL, 0, Moves, true);
 
-    Asm->EmitAlignment(2, 0, 0, false);
+    // On Darwin the linker honors the alignment of eh_frame, which means it
+    // must be 8-byte on 64-bit targets to match what gcc does.  Otherwise
+    // you get holes which confuse readers of eh_frame.
+    Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, 
+                       0, 0, false);
     EmitLabel("eh_frame_common_end", Index);
-    
+
     Asm->EOL();
   }
-  
+
   /// EmitEHFrame - Emit function exception frame information.
   ///
   void EmitEHFrame(const FunctionEHFrameInfo &EHFrameInfo) {
@@ -2936,36 +3015,37 @@
                         true, true, false);
       Asm->EOL("FDE CIE offset");
 
-      EmitReference("eh_func_begin", EHFrameInfo.Number, true);
+      EmitReference("eh_func_begin", EHFrameInfo.Number, true, true);
       Asm->EOL("FDE initial location");
       EmitDifference("eh_func_end", EHFrameInfo.Number,
-                     "eh_func_begin", EHFrameInfo.Number);
+                     "eh_func_begin", EHFrameInfo.Number, true);
       Asm->EOL("FDE address range");
-      
+
       // If there is a personality and landing pads then point to the language
       // specific data area in the exception table.
       if (EHFrameInfo.PersonalityIndex) {
-        Asm->EmitULEB128Bytes(TAI->getShortenEHDataOn64Bit() ? 8 : 4);
+        Asm->EmitULEB128Bytes(4);
         Asm->EOL("Augmentation size");
-        
-        if (EHFrameInfo.hasLandingPads) {
-          EmitReference("exception", EHFrameInfo.Number, true);
-        } else if (TD->getPointerSize() == 8) {
-          Asm->EmitInt64((int)0);
-        } else {
+
+        if (EHFrameInfo.hasLandingPads)
+          EmitReference("exception", EHFrameInfo.Number, true, true);
+        else
           Asm->EmitInt32((int)0);
-        }
         Asm->EOL("Language Specific Data Area");
       } else {
         Asm->EmitULEB128Bytes(0);
         Asm->EOL("Augmentation size");
       }
-      
+
       // Indicate locations of function specific  callee saved registers in
       // frame.
       EmitFrameMoves("eh_func_begin", EHFrameInfo.Number, EHFrameInfo.Moves, true);
       
-      Asm->EmitAlignment(2, 0, 0, false);
+      // On Darwin the linker honors the alignment of eh_frame, which means it
+      // must be 8-byte on 64-bit targets to match what gcc does.  Otherwise
+      // you get holes which confuse readers of eh_frame.
+      Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, 
+                         0, 0, false);
       EmitLabel("eh_frame_end", EHFrameInfo.Number);
     
       // If the function is marked used, this table should be also.  We cannot 
@@ -3190,7 +3270,7 @@
          I != E; ++I) {
       for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end();
            MI != E; ++MI) {
-        if (MI->getOpcode() != TargetInstrInfo::LABEL) {
+        if (!MI->isLabel()) {
           SawPotentiallyThrowing |= MI->getDesc().isCall();
           continue;
         }
@@ -3233,7 +3313,7 @@
 
           // Try to merge with the previous call-site.
           if (PreviousIsInvoke) {
-            CallSiteEntry &Prev = CallSites[CallSites.size()-1];
+            CallSiteEntry &Prev = CallSites.back();
             if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) {
               // Extend the range of the previous entry.
               Prev.EndLabel = Site.EndLabel;
@@ -3259,13 +3339,20 @@
     }
 
     // Final tallies.
-    unsigned SizeSites = CallSites.size() * (sizeof(int32_t) + // Site start.
-                                             sizeof(int32_t) + // Site length.
-                                             sizeof(int32_t)); // Landing pad.
+
+    // Call sites.
+    const unsigned SiteStartSize  = sizeof(int32_t); // DW_EH_PE_udata4
+    const unsigned SiteLengthSize = sizeof(int32_t); // DW_EH_PE_udata4
+    const unsigned LandingPadSize = sizeof(int32_t); // DW_EH_PE_udata4
+    unsigned SizeSites = CallSites.size() * (SiteStartSize +
+                                             SiteLengthSize +
+                                             LandingPadSize);
     for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
       SizeSites += Asm->SizeULEB128(CallSites[i].Action);
 
-    unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
+    // Type infos.
+    const unsigned TypeInfoSize = TD->getPointerSize(); // DW_EH_PE_absptr
+    unsigned SizeTypes = TypeInfos.size() * TypeInfoSize;
 
     unsigned TypeOffset = sizeof(int8_t) + // Call site format
                           Asm->SizeULEB128(SizeSites) + // Call-site table length
@@ -3315,27 +3402,22 @@
       }
 
       EmitSectionOffset(BeginTag, "eh_func_begin", BeginNumber, SubprogramCount,
-                        TAI->getShortenEHDataOn64Bit(), true);
+                        true, true);
       Asm->EOL("Region start");
 
       if (!S.EndLabel) {
         EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber,
-                       TAI->getShortenEHDataOn64Bit());
+                       true);
       } else {
-        EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, 
-                       TAI->getShortenEHDataOn64Bit());
+        EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, true);
       }
       Asm->EOL("Region length");
 
-      if (!S.PadLabel) {
-        if (TD->getPointerSize() == sizeof(int32_t) || TAI->getShortenEHDataOn64Bit())
-          Asm->EmitInt32(0);
-        else
-          Asm->EmitInt64(0);
-      } else {
+      if (!S.PadLabel)
+        Asm->EmitInt32(0);
+      else
         EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount,
-                          TAI->getShortenEHDataOn64Bit(), true);
-      }
+                          true, true);
       Asm->EOL("Landing pad");
 
       Asm->EmitULEB128Bytes(S.Action);
@@ -3430,9 +3512,7 @@
         shouldEmitTable = true;
 
       // See if we need frame move info.
-      if (MMI->hasDebugInfo() || 
-          !MF->getFunction()->doesNotThrow() ||
-          UnwindTablesMandatory)
+      if (!MF->getFunction()->doesNotThrow() || UnwindTablesMandatory)
         shouldEmitMoves = true;
 
       if (shouldEmitMoves || shouldEmitTable)
@@ -3610,6 +3690,23 @@
 
 /// EmitValue - Emit delta value.
 ///
+void DIESectionOffset::EmitValue(DwarfDebug &DD, unsigned Form) {
+  bool IsSmall = Form == DW_FORM_data4;
+  DD.EmitSectionOffset(Label.Tag, Section.Tag,
+                       Label.Number, Section.Number, IsSmall, IsEH, UseSet);
+}
+
+/// SizeOf - Determine size of delta value in bytes.
+///
+unsigned DIESectionOffset::SizeOf(const DwarfDebug &DD, unsigned Form) const {
+  if (Form == DW_FORM_data4) return 4;
+  return DD.getTargetData()->getPointerSize();
+}
+    
+//===----------------------------------------------------------------------===//
+
+/// EmitValue - Emit delta value.
+///
 void DIEDelta::EmitValue(DwarfDebug &DD, unsigned Form) {
   bool IsSmall = Form == DW_FORM_data4;
   DD.EmitDifference(LabelHi, LabelLo, IsSmall);
@@ -3636,7 +3733,7 @@
 ///
 unsigned DIEBlock::ComputeSize(DwarfDebug &DD) {
   if (!Size) {
-    const std::vector<DIEAbbrevData> &AbbrevData = Abbrev.getData();
+    const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev.getData();
     
     for (unsigned i = 0, N = Values.size(); i < N; ++i) {
       Size += Values[i]->SizeOf(DD, AbbrevData[i].getForm());
@@ -3656,7 +3753,7 @@
   default: assert(0 && "Improper form for block");          break;
   }
   
-  const std::vector<DIEAbbrevData> &AbbrevData = Abbrev.getData();
+  const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev.getData();
 
   for (unsigned i = 0, N = Values.size(); i < N; ++i) {
     DD.getAsm()->EOL();
@@ -3729,7 +3826,7 @@
   }
   O << "\n";
 
-  const std::vector<DIEAbbrevData> &Data = Abbrev.getData();
+  const SmallVector<DIEAbbrevData, 8> &Data = Abbrev.getData();
   
   IndentCount += 2;
   for (unsigned i = 0, N = Data.size(); i < N; ++i) {

Modified: llvm/branches/non-call-eh/lib/CodeGen/ELFWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/ELFWriter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/ELFWriter.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/ELFWriter.cpp Sun Jul  6 15:45:41 2008
@@ -229,7 +229,7 @@
 
   // This should change for shared objects.
   FHOut.outhalf(1);                 // e_type = ET_REL
-  FHOut.outword(TM.getELFWriterInfo()->getEMachine()); // target-defined
+  FHOut.outhalf(TM.getELFWriterInfo()->getEMachine()); // target-defined
   FHOut.outword(1);                 // e_version = 1
   FHOut.outaddr(0);                 // e_entry = 0 -> no entry point in .o file
   FHOut.outaddr(0);                 // e_phoff = 0 -> no program header for .o
@@ -282,7 +282,8 @@
     // If this global is part of the common block, add it now.  Variables are
     // part of the common block if they are zero initialized and allowed to be
     // merged with other symbols.
-    if (GV->hasLinkOnceLinkage() || GV->hasWeakLinkage()) {
+    if (GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() ||
+        GV->hasCommonLinkage()) {
       ELFSym CommonSym(GV);
       // Value for common symbols is the alignment required.
       CommonSym.Value = Align;
@@ -313,7 +314,7 @@
     BSSSym.SetType(ELFSym::STT_OBJECT);
 
     switch (GV->getLinkage()) {
-    default:  // weak/linkonce handled above
+    default:  // weak/linkonce/common handled above
       assert(0 && "Unexpected linkage type!");
     case GlobalValue::AppendingLinkage:  // FIXME: This should be improved!
     case GlobalValue::ExternalLinkage:

Modified: llvm/branches/non-call-eh/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/IfConversion.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/IfConversion.cpp Sun Jul  6 15:45:41 2008
@@ -149,7 +149,7 @@
     IfConverter() : MachineFunctionPass((intptr_t)&ID) {}
 
     virtual bool runOnMachineFunction(MachineFunction &MF);
-    virtual const char *getPassName() const { return "If converter"; }
+    virtual const char *getPassName() const { return "If Converter"; }
 
   private:
     bool ReverseBranchCondition(BBInfo &BBI);
@@ -215,6 +215,9 @@
   char IfConverter::ID = 0;
 }
 
+static RegisterPass<IfConverter>
+X("if-converter", "If Converter");
+
 FunctionPass *llvm::createIfConverterPass() { return new IfConverter(); }
 
 bool IfConverter::runOnMachineFunction(MachineFunction &MF) {

Modified: llvm/branches/non-call-eh/lib/CodeGen/IntrinsicLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/IntrinsicLowering.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/IntrinsicLowering.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/IntrinsicLowering.cpp Sun Jul  6 15:45:41 2008
@@ -173,76 +173,76 @@
   switch(BitSize) {
   default: assert(0 && "Unhandled type size of value to byteswap!");
   case 16: {
-    Value *Tmp1 = BinaryOperator::createShl(V,
+    Value *Tmp1 = BinaryOperator::CreateShl(V,
                                 ConstantInt::get(V->getType(),8),"bswap.2",IP);
-    Value *Tmp2 = BinaryOperator::createLShr(V,
+    Value *Tmp2 = BinaryOperator::CreateLShr(V,
                                 ConstantInt::get(V->getType(),8),"bswap.1",IP);
-    V = BinaryOperator::createOr(Tmp1, Tmp2, "bswap.i16", IP);
+    V = BinaryOperator::CreateOr(Tmp1, Tmp2, "bswap.i16", IP);
     break;
   }
   case 32: {
-    Value *Tmp4 = BinaryOperator::createShl(V,
+    Value *Tmp4 = BinaryOperator::CreateShl(V,
                               ConstantInt::get(V->getType(),24),"bswap.4", IP);
-    Value *Tmp3 = BinaryOperator::createShl(V,
+    Value *Tmp3 = BinaryOperator::CreateShl(V,
                               ConstantInt::get(V->getType(),8),"bswap.3",IP);
-    Value *Tmp2 = BinaryOperator::createLShr(V,
+    Value *Tmp2 = BinaryOperator::CreateLShr(V,
                               ConstantInt::get(V->getType(),8),"bswap.2",IP);
-    Value *Tmp1 = BinaryOperator::createLShr(V,
+    Value *Tmp1 = BinaryOperator::CreateLShr(V,
                               ConstantInt::get(V->getType(),24),"bswap.1", IP);
-    Tmp3 = BinaryOperator::createAnd(Tmp3, 
+    Tmp3 = BinaryOperator::CreateAnd(Tmp3, 
                                      ConstantInt::get(Type::Int32Ty, 0xFF0000),
                                      "bswap.and3", IP);
-    Tmp2 = BinaryOperator::createAnd(Tmp2, 
+    Tmp2 = BinaryOperator::CreateAnd(Tmp2, 
                                      ConstantInt::get(Type::Int32Ty, 0xFF00),
                                      "bswap.and2", IP);
-    Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or1", IP);
-    Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or2", IP);
-    V = BinaryOperator::createOr(Tmp4, Tmp2, "bswap.i32", IP);
+    Tmp4 = BinaryOperator::CreateOr(Tmp4, Tmp3, "bswap.or1", IP);
+    Tmp2 = BinaryOperator::CreateOr(Tmp2, Tmp1, "bswap.or2", IP);
+    V = BinaryOperator::CreateOr(Tmp4, Tmp2, "bswap.i32", IP);
     break;
   }
   case 64: {
-    Value *Tmp8 = BinaryOperator::createShl(V,
+    Value *Tmp8 = BinaryOperator::CreateShl(V,
                               ConstantInt::get(V->getType(),56),"bswap.8", IP);
-    Value *Tmp7 = BinaryOperator::createShl(V,
+    Value *Tmp7 = BinaryOperator::CreateShl(V,
                               ConstantInt::get(V->getType(),40),"bswap.7", IP);
-    Value *Tmp6 = BinaryOperator::createShl(V,
+    Value *Tmp6 = BinaryOperator::CreateShl(V,
                               ConstantInt::get(V->getType(),24),"bswap.6", IP);
-    Value *Tmp5 = BinaryOperator::createShl(V,
+    Value *Tmp5 = BinaryOperator::CreateShl(V,
                               ConstantInt::get(V->getType(),8),"bswap.5", IP);
-    Value* Tmp4 = BinaryOperator::createLShr(V,
+    Value* Tmp4 = BinaryOperator::CreateLShr(V,
                               ConstantInt::get(V->getType(),8),"bswap.4", IP);
-    Value* Tmp3 = BinaryOperator::createLShr(V,
+    Value* Tmp3 = BinaryOperator::CreateLShr(V,
                               ConstantInt::get(V->getType(),24),"bswap.3", IP);
-    Value* Tmp2 = BinaryOperator::createLShr(V,
+    Value* Tmp2 = BinaryOperator::CreateLShr(V,
                               ConstantInt::get(V->getType(),40),"bswap.2", IP);
-    Value* Tmp1 = BinaryOperator::createLShr(V,
+    Value* Tmp1 = BinaryOperator::CreateLShr(V,
                               ConstantInt::get(V->getType(),56),"bswap.1", IP);
-    Tmp7 = BinaryOperator::createAnd(Tmp7,
+    Tmp7 = BinaryOperator::CreateAnd(Tmp7,
                              ConstantInt::get(Type::Int64Ty, 
                                0xFF000000000000ULL),
                              "bswap.and7", IP);
-    Tmp6 = BinaryOperator::createAnd(Tmp6,
+    Tmp6 = BinaryOperator::CreateAnd(Tmp6,
                              ConstantInt::get(Type::Int64Ty, 0xFF0000000000ULL),
                              "bswap.and6", IP);
-    Tmp5 = BinaryOperator::createAnd(Tmp5,
+    Tmp5 = BinaryOperator::CreateAnd(Tmp5,
                              ConstantInt::get(Type::Int64Ty, 0xFF00000000ULL),
                              "bswap.and5", IP);
-    Tmp4 = BinaryOperator::createAnd(Tmp4,
+    Tmp4 = BinaryOperator::CreateAnd(Tmp4,
                              ConstantInt::get(Type::Int64Ty, 0xFF000000ULL),
                              "bswap.and4", IP);
-    Tmp3 = BinaryOperator::createAnd(Tmp3,
+    Tmp3 = BinaryOperator::CreateAnd(Tmp3,
                              ConstantInt::get(Type::Int64Ty, 0xFF0000ULL),
                              "bswap.and3", IP);
-    Tmp2 = BinaryOperator::createAnd(Tmp2,
+    Tmp2 = BinaryOperator::CreateAnd(Tmp2,
                              ConstantInt::get(Type::Int64Ty, 0xFF00ULL),
                              "bswap.and2", IP);
-    Tmp8 = BinaryOperator::createOr(Tmp8, Tmp7, "bswap.or1", IP);
-    Tmp6 = BinaryOperator::createOr(Tmp6, Tmp5, "bswap.or2", IP);
-    Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, "bswap.or3", IP);
-    Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, "bswap.or4", IP);
-    Tmp8 = BinaryOperator::createOr(Tmp8, Tmp6, "bswap.or5", IP);
-    Tmp4 = BinaryOperator::createOr(Tmp4, Tmp2, "bswap.or6", IP);
-    V = BinaryOperator::createOr(Tmp8, Tmp4, "bswap.i64", IP);
+    Tmp8 = BinaryOperator::CreateOr(Tmp8, Tmp7, "bswap.or1", IP);
+    Tmp6 = BinaryOperator::CreateOr(Tmp6, Tmp5, "bswap.or2", IP);
+    Tmp4 = BinaryOperator::CreateOr(Tmp4, Tmp3, "bswap.or3", IP);
+    Tmp2 = BinaryOperator::CreateOr(Tmp2, Tmp1, "bswap.or4", IP);
+    Tmp8 = BinaryOperator::CreateOr(Tmp8, Tmp6, "bswap.or5", IP);
+    Tmp4 = BinaryOperator::CreateOr(Tmp4, Tmp2, "bswap.or6", IP);
+    V = BinaryOperator::CreateOr(Tmp8, Tmp4, "bswap.i64", IP);
     break;
   }
   }
@@ -269,16 +269,16 @@
     for (unsigned i = 1, ct = 0; i < (BitSize>64 ? 64 : BitSize); 
          i <<= 1, ++ct) {
       Value *MaskCst = ConstantInt::get(V->getType(), MaskValues[ct]);
-      Value *LHS = BinaryOperator::createAnd(
+      Value *LHS = BinaryOperator::CreateAnd(
                      PartValue, MaskCst, "cppop.and1", IP);
-      Value *VShift = BinaryOperator::createLShr(PartValue,
+      Value *VShift = BinaryOperator::CreateLShr(PartValue,
                         ConstantInt::get(V->getType(), i), "ctpop.sh", IP);
-      Value *RHS = BinaryOperator::createAnd(VShift, MaskCst, "cppop.and2", IP);
-      PartValue = BinaryOperator::createAdd(LHS, RHS, "ctpop.step", IP);
+      Value *RHS = BinaryOperator::CreateAnd(VShift, MaskCst, "cppop.and2", IP);
+      PartValue = BinaryOperator::CreateAdd(LHS, RHS, "ctpop.step", IP);
     }
-    Count = BinaryOperator::createAdd(PartValue, Count, "ctpop.part", IP);
+    Count = BinaryOperator::CreateAdd(PartValue, Count, "ctpop.part", IP);
     if (BitSize > 64) {
-      V = BinaryOperator::createLShr(V, ConstantInt::get(V->getType(), 64), 
+      V = BinaryOperator::CreateLShr(V, ConstantInt::get(V->getType(), 64), 
                                      "ctpop.part.sh", IP);
       BitSize -= 64;
     }
@@ -294,11 +294,11 @@
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   for (unsigned i = 1; i < BitSize; i <<= 1) {
     Value *ShVal = ConstantInt::get(V->getType(), i);
-    ShVal = BinaryOperator::createLShr(V, ShVal, "ctlz.sh", IP);
-    V = BinaryOperator::createOr(V, ShVal, "ctlz.step", IP);
+    ShVal = BinaryOperator::CreateLShr(V, ShVal, "ctlz.sh", IP);
+    V = BinaryOperator::CreateOr(V, ShVal, "ctlz.step", IP);
   }
 
-  V = BinaryOperator::createNot(V, "", IP);
+  V = BinaryOperator::CreateNot(V, "", IP);
   return LowerCTPOP(V, IP);
 }
 
@@ -355,10 +355,10 @@
 
     // Cast Hi and Lo to the size of Val so the widths are all the same
     if (Hi->getType() != Val->getType())
-      Hi = CastInst::createIntegerCast(Hi, Val->getType(), false, 
+      Hi = CastInst::CreateIntegerCast(Hi, Val->getType(), false, 
                                          "tmp", CurBB);
     if (Lo->getType() != Val->getType())
-      Lo = CastInst::createIntegerCast(Lo, Val->getType(), false, 
+      Lo = CastInst::CreateIntegerCast(Lo, Val->getType(), false, 
                                           "tmp", CurBB);
 
     // Compute a few things that both cases will need, up front.
@@ -373,12 +373,12 @@
 
     // First, copmute the number of bits in the forward case.
     Instruction* FBitSize = 
-      BinaryOperator::createSub(Hi, Lo,"fbits", FwdSize);
+      BinaryOperator::CreateSub(Hi, Lo,"fbits", FwdSize);
     BranchInst::Create(Compute, FwdSize);
 
     // Second, compute the number of bits in the reverse case.
     Instruction* RBitSize = 
-      BinaryOperator::createSub(Lo, Hi, "rbits", RevSize);
+      BinaryOperator::CreateSub(Lo, Hi, "rbits", RevSize);
     BranchInst::Create(Compute, RevSize);
 
     // Now, compute the bit range. Start by getting the bitsize and the shift
@@ -402,17 +402,17 @@
 
     // Increment the bit size
     Instruction *BitSizePlusOne = 
-      BinaryOperator::createAdd(BitSize, One, "bits", Compute);
+      BinaryOperator::CreateAdd(BitSize, One, "bits", Compute);
 
     // Create a Mask to zero out the high order bits.
     Instruction* Mask = 
-      BinaryOperator::createShl(AllOnes, BitSizePlusOne, "mask", Compute);
-    Mask = BinaryOperator::createNot(Mask, "mask", Compute);
+      BinaryOperator::CreateShl(AllOnes, BitSizePlusOne, "mask", Compute);
+    Mask = BinaryOperator::CreateNot(Mask, "mask", Compute);
 
     // Shift the bits down and apply the mask
     Instruction* FRes = 
-      BinaryOperator::createLShr(Val, ShiftAmt, "fres", Compute);
-    FRes = BinaryOperator::createAnd(FRes, Mask, "fres", Compute);
+      BinaryOperator::CreateLShr(Val, ShiftAmt, "fres", Compute);
+    FRes = BinaryOperator::CreateAnd(FRes, Mask, "fres", Compute);
     BranchInst::Create(Reverse, RsltBlk, Cmp, Compute);
 
     // In the Reverse block we have the mask already in FRes but we must reverse
@@ -435,22 +435,22 @@
     RRes->addIncoming(Zero, Compute);
 
     // Decrement the counter
-    Instruction *Decr = BinaryOperator::createSub(Count, One, "decr", Reverse);
+    Instruction *Decr = BinaryOperator::CreateSub(Count, One, "decr", Reverse);
     Count->addIncoming(Decr, Reverse);
 
     // Compute the Bit that we want to move
     Instruction *Bit = 
-      BinaryOperator::createAnd(BitsToShift, One, "bit", Reverse);
+      BinaryOperator::CreateAnd(BitsToShift, One, "bit", Reverse);
 
     // Compute the new value for next iteration.
     Instruction *NewVal = 
-      BinaryOperator::createLShr(BitsToShift, One, "rshift", Reverse);
+      BinaryOperator::CreateLShr(BitsToShift, One, "rshift", Reverse);
     BitsToShift->addIncoming(NewVal, Reverse);
 
     // Shift the bit into the low bits of the result.
     Instruction *NewRes = 
-      BinaryOperator::createShl(RRes, One, "lshift", Reverse);
-    NewRes = BinaryOperator::createOr(NewRes, Bit, "addbit", Reverse);
+      BinaryOperator::CreateShl(RRes, One, "lshift", Reverse);
+    NewRes = BinaryOperator::CreateOr(NewRes, Bit, "addbit", Reverse);
     RRes->addIncoming(NewRes, Reverse);
     
     // Terminate loop if we've moved all the bits.
@@ -543,8 +543,8 @@
       new ICmpInst(ICmpInst::ICMP_ULT, Lo, Hi, "", entry);
     SelectInst* Hi_pn = SelectInst::Create(is_forward, Hi, Lo, "", entry);
     SelectInst* Lo_pn = SelectInst::Create(is_forward, Lo, Hi, "", entry);
-    BinaryOperator* NumBits = BinaryOperator::createSub(Hi_pn, Lo_pn, "",entry);
-    NumBits = BinaryOperator::createAdd(NumBits, One, "", entry);
+    BinaryOperator* NumBits = BinaryOperator::CreateSub(Hi_pn, Lo_pn, "",entry);
+    NumBits = BinaryOperator::CreateAdd(NumBits, One, "", entry);
     // Now, convert Lo and Hi to ValTy bit width
     if (ValBits > 32) {
       Lo = new ZExtInst(Lo_pn, ValTy, "", entry);
@@ -559,12 +559,12 @@
 
     // BASIC BLOCK: large
     Instruction* MaskBits = 
-      BinaryOperator::createSub(RepBitWidth, NumBits, "", large);
-    MaskBits = CastInst::createIntegerCast(MaskBits, RepMask->getType(), 
+      BinaryOperator::CreateSub(RepBitWidth, NumBits, "", large);
+    MaskBits = CastInst::CreateIntegerCast(MaskBits, RepMask->getType(), 
                                            false, "", large);
     BinaryOperator* Mask1 = 
-      BinaryOperator::createLShr(RepMask, MaskBits, "", large);
-    BinaryOperator* Rep2 = BinaryOperator::createAnd(Mask1, Rep, "", large);
+      BinaryOperator::CreateLShr(RepMask, MaskBits, "", large);
+    BinaryOperator* Rep2 = BinaryOperator::CreateAnd(Mask1, Rep, "", large);
     BranchInst::Create(small, large);
 
     // BASIC BLOCK: small
@@ -598,19 +598,19 @@
     RRes->addIncoming(ValZero, small);
 
     // Decrement the loop counter by one
-    Instruction *Decr = BinaryOperator::createSub(Count, One, "", reverse);
+    Instruction *Decr = BinaryOperator::CreateSub(Count, One, "", reverse);
     Count->addIncoming(Decr, reverse);
 
     // Get the bit that we want to move into the result
-    Value *Bit = BinaryOperator::createAnd(BitsToShift, ValOne, "", reverse);
+    Value *Bit = BinaryOperator::CreateAnd(BitsToShift, ValOne, "", reverse);
 
     // Compute the new value of the bits to shift for the next iteration.
-    Value *NewVal = BinaryOperator::createLShr(BitsToShift, ValOne,"", reverse);
+    Value *NewVal = BinaryOperator::CreateLShr(BitsToShift, ValOne,"", reverse);
     BitsToShift->addIncoming(NewVal, reverse);
 
     // Shift the bit we extracted into the low bit of the result.
-    Instruction *NewRes = BinaryOperator::createShl(RRes, ValOne, "", reverse);
-    NewRes = BinaryOperator::createOr(NewRes, Bit, "", reverse);
+    Instruction *NewRes = BinaryOperator::CreateShl(RRes, ValOne, "", reverse);
+    NewRes = BinaryOperator::CreateOr(NewRes, Bit, "", reverse);
     RRes->addIncoming(NewRes, reverse);
     
     // Terminate loop if we've moved all the bits.
@@ -622,14 +622,14 @@
     Rplcmnt->reserveOperandSpace(2);
     Rplcmnt->addIncoming(NewRes, reverse);
     Rplcmnt->addIncoming(Rep4, small);
-    Value* t0   = CastInst::createIntegerCast(NumBits,ValTy,false,"",result);
-    Value* t1   = BinaryOperator::createShl(ValMask, Lo, "", result);
-    Value* t2   = BinaryOperator::createNot(t1, "", result);
-    Value* t3   = BinaryOperator::createShl(t1, t0, "", result);
-    Value* t4   = BinaryOperator::createOr(t2, t3, "", result);
-    Value* t5   = BinaryOperator::createAnd(t4, Val, "", result);
-    Value* t6   = BinaryOperator::createShl(Rplcmnt, Lo, "", result);
-    Value* Rslt = BinaryOperator::createOr(t5, t6, "part_set", result);
+    Value* t0   = CastInst::CreateIntegerCast(NumBits,ValTy,false,"",result);
+    Value* t1   = BinaryOperator::CreateShl(ValMask, Lo, "", result);
+    Value* t2   = BinaryOperator::CreateNot(t1, "", result);
+    Value* t3   = BinaryOperator::CreateShl(t1, t0, "", result);
+    Value* t4   = BinaryOperator::CreateOr(t2, t3, "", result);
+    Value* t5   = BinaryOperator::CreateAnd(t4, Val, "", result);
+    Value* t6   = BinaryOperator::CreateShl(Rplcmnt, Lo, "", result);
+    Value* Rslt = BinaryOperator::CreateOr(t5, t6, "part_set", result);
     ReturnInst::Create(Rslt, result);
   }
 
@@ -704,10 +704,10 @@
   case Intrinsic::cttz: {
     // cttz(x) -> ctpop(~X & (X-1))
     Value *Src = CI->getOperand(1);
-    Value *NotSrc = BinaryOperator::createNot(Src, Src->getName()+".not", CI);
+    Value *NotSrc = BinaryOperator::CreateNot(Src, Src->getName()+".not", CI);
     Value *SrcM1 = ConstantInt::get(Src->getType(), 1);
-    SrcM1 = BinaryOperator::createSub(Src, SrcM1, "", CI);
-    Src = LowerCTPOP(BinaryOperator::createAnd(NotSrc, SrcM1, "", CI), CI);
+    SrcM1 = BinaryOperator::CreateSub(Src, SrcM1, "", CI);
+    Src = LowerCTPOP(BinaryOperator::CreateAnd(NotSrc, SrcM1, "", CI), CI);
     CI->replaceAllUsesWith(Src);
     break;
   }

Modified: llvm/branches/non-call-eh/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/LLVMTargetMachine.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/LLVMTargetMachine.cpp Sun Jul  6 15:45:41 2008
@@ -38,12 +38,9 @@
 EnableSinking("enable-sinking", cl::init(false), cl::Hidden,
               cl::desc("Perform sinking on machine code"));
 static cl::opt<bool>
-AlignLoops("align-loops", cl::init(true), cl::Hidden,
-              cl::desc("Align loop headers"));
-static cl::opt<bool>
-PerformLICM("machine-licm",
-            cl::init(false), cl::Hidden,
-            cl::desc("Perform loop-invariant code motion on machine code"));
+EnableLICM("machine-licm",
+           cl::init(false), cl::Hidden,
+           cl::desc("Perform loop-invariant code motion on machine code"));
 
 // When this works it will be on by default.
 static cl::opt<bool>
@@ -88,30 +85,41 @@
   if (PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
 
-  if (PerformLICM)
+  if (EnableLICM)
     PM.add(createMachineLICMPass());
   
   if (EnableSinking)
     PM.add(createMachineSinkingPass());
 
+  // Run pre-ra passes.
+  if (addPreRegAlloc(PM, Fast) && PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
   // Perform register allocation to convert to a concrete x86 representation
   PM.add(createRegisterAllocator());
   
-  if (PrintMachineCode)
+  // Perform stack slot coloring.
+  if (!Fast)
+    PM.add(createStackSlotColoringPass());
+
+  if (PrintMachineCode)  // Print the register-allocated code
     PM.add(createMachineFunctionPrinterPass(cerr));
-    
-  PM.add(createLowerSubregsPass());
   
-  if (PrintMachineCode)  // Print the subreg lowered code
-    PM.add(createMachineFunctionPrinterPass(cerr));
-
   // Run post-ra passes.
   if (addPostRegAlloc(PM, Fast) && PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
 
+  PM.add(createLowerSubregsPass());
+  
+  if (PrintMachineCode)  // Print the subreg lowered code
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
   // Insert prolog/epilog code.  Eliminate abstract frame index references...
   PM.add(createPrologEpilogCodeInserter());
   
+  if (PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+  
   // Second pass scheduler.
   if (!Fast && !DisablePostRAScheduler)
     PM.add(createPostRAScheduler());
@@ -136,7 +144,7 @@
   if (addPreEmitPass(PM, Fast) && PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
 
-  if (AlignLoops && !OptimizeForSize)
+  if (!Fast && !OptimizeForSize)
     PM.add(createLoopAlignerPass());
 
   switch (FileType) {
@@ -214,31 +222,42 @@
   if (PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
 
-  if (PerformLICM)
+  if (EnableLICM)
     PM.add(createMachineLICMPass());
   
   if (EnableSinking)
     PM.add(createMachineSinkingPass());
 
-  // Perform register allocation to convert to a concrete x86 representation
+  // Run pre-ra passes.
+  if (addPreRegAlloc(PM, Fast) && PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
+  // Perform register allocation.
   PM.add(createRegisterAllocator());
-  
+
+  // Perform stack slot coloring.
+  if (!Fast)
+    PM.add(createStackSlotColoringPass());
+
   if (PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
     
+  // Run post-ra passes.
+  if (addPostRegAlloc(PM, Fast) && PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
+  if (PrintMachineCode)  // Print the register-allocated code
+    PM.add(createMachineFunctionPrinterPass(cerr));
+  
   PM.add(createLowerSubregsPass());
   
   if (PrintMachineCode)  // Print the subreg lowered code
     PM.add(createMachineFunctionPrinterPass(cerr));
 
-  // Run post-ra passes.
-  if (addPostRegAlloc(PM, Fast) && PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(cerr));
-
   // Insert prolog/epilog code.  Eliminate abstract frame index references...
   PM.add(createPrologEpilogCodeInserter());
   
-  if (PrintMachineCode)  // Print the register-allocated code
+  if (PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
   
   // Second pass scheduler.
@@ -250,6 +269,7 @@
     PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
 
   PM.add(createGCMachineCodeAnalysisPass());
+
   if (PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
   

Modified: llvm/branches/non-call-eh/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/LiveInterval.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/LiveInterval.cpp Sun Jul  6 15:45:41 2008
@@ -358,6 +358,20 @@
   return end();
 }
 
+/// findDefinedVNInfo - Find the VNInfo that's defined at the specified index
+/// (register interval) or defined by the specified register (stack inteval).
+VNInfo *LiveInterval::findDefinedVNInfo(unsigned DefIdxOrReg) const {
+  VNInfo *VNI = NULL;
+  for (LiveInterval::const_vni_iterator i = vni_begin(), e = vni_end();
+       i != e; ++i)
+    if ((*i)->def == DefIdxOrReg) {
+      VNI = *i;
+      break;
+    }
+  return VNI;
+}
+
+
 /// join - Join two live intervals (this, and other) together.  This applies
 /// mappings to the value numbers in the LHS/RHS intervals as specified.  If
 /// the intervals are not joinable, this aborts.
@@ -664,7 +678,9 @@
 
 void LiveInterval::print(std::ostream &OS,
                          const TargetRegisterInfo *TRI) const {
-  if (TRI && TargetRegisterInfo::isPhysicalRegister(reg))
+  if (isStackSlot())
+    OS << "SS#" << getStackSlotIndex();
+  else if (TRI && TargetRegisterInfo::isPhysicalRegister(reg))
     OS << TRI->getName(reg);
   else
     OS << "%reg" << reg;
@@ -672,7 +688,7 @@
   OS << ',' << weight;
 
   if (empty())
-    OS << "EMPTY";
+    OS << " EMPTY";
   else {
     OS << " = ";
     for (LiveInterval::Ranges::const_iterator I = ranges.begin(),

Modified: llvm/branches/non-call-eh/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Jul  6 15:45:41 2008
@@ -36,16 +36,14 @@
 #include <cmath>
 using namespace llvm;
 
-namespace {
-  // Hidden options for help debugging.
-  cl::opt<bool> DisableReMat("disable-rematerialization", 
-                              cl::init(false), cl::Hidden);
-
-  cl::opt<bool> SplitAtBB("split-intervals-at-bb", 
-                          cl::init(true), cl::Hidden);
-  cl::opt<int> SplitLimit("split-limit",
-                          cl::init(-1), cl::Hidden);
-}
+// Hidden options for help debugging.
+static cl::opt<bool> DisableReMat("disable-rematerialization", 
+                                  cl::init(false), cl::Hidden);
+
+static cl::opt<bool> SplitAtBB("split-intervals-at-bb", 
+                               cl::init(true), cl::Hidden);
+static cl::opt<int> SplitLimit("split-limit",
+                               cl::init(-1), cl::Hidden);
 
 STATISTIC(numIntervals, "Number of original intervals");
 STATISTIC(numIntervalsAfter, "Number of intervals after coalescing");
@@ -53,9 +51,7 @@
 STATISTIC(numSplits   , "Number of intervals split");
 
 char LiveIntervals::ID = 0;
-namespace {
-  RegisterPass<LiveIntervals> X("liveintervals", "Live Interval Analysis");
-}
+static RegisterPass<LiveIntervals> X("liveintervals", "Live Interval Analysis");
 
 void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addPreserved<LiveVariables>();
@@ -69,6 +65,7 @@
 }
 
 void LiveIntervals::releaseMemory() {
+  MBB2IdxMap.clear();
   Idx2MBBMap.clear();
   mi2iMap_.clear();
   i2miMap_.clear();
@@ -79,17 +76,14 @@
     delete ClonedMIs[i];
 }
 
-/// runOnMachineFunction - Register allocate the whole function
-///
-bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
-  mf_ = &fn;
-  mri_ = &mf_->getRegInfo();
-  tm_ = &fn.getTarget();
-  tri_ = tm_->getRegisterInfo();
-  tii_ = tm_->getInstrInfo();
-  lv_ = &getAnalysis<LiveVariables>();
-  allocatableRegs_ = tri_->getAllocatableSet(fn);
-
+void LiveIntervals::computeNumbering() {
+  Index2MiMap OldI2MI = i2miMap_;
+  
+  Idx2MBBMap.clear();
+  MBB2IdxMap.clear();
+  mi2iMap_.clear();
+  i2miMap_.clear();
+  
   // Number MachineInstrs and MachineBasicBlocks.
   // Initialize MBB indexes to a sentinal.
   MBB2IdxMap.resize(mf_->getNumBlockIDs(), std::make_pair(~0U,~0U));
@@ -106,15 +100,120 @@
       i2miMap_.push_back(I);
       MIIndex += InstrSlots::NUM;
     }
-
+    
+    if (StartIdx == MIIndex) {
+      // Empty MBB
+      MIIndex += InstrSlots::NUM;
+      i2miMap_.push_back(0);
+    }
     // Set the MBB2IdxMap entry for this MBB.
-    MBB2IdxMap[MBB->getNumber()] = (StartIdx == MIIndex)
-      ? std::make_pair(StartIdx, StartIdx)  // Empty MBB
-      : std::make_pair(StartIdx, MIIndex - 1);
+    MBB2IdxMap[MBB->getNumber()] = std::make_pair(StartIdx, MIIndex - 1);
     Idx2MBBMap.push_back(std::make_pair(StartIdx, MBB));
   }
   std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare());
+  
+  if (!OldI2MI.empty())
+    for (iterator I = begin(), E = end(); I != E; ++I)
+      for (LiveInterval::iterator LI = I->second.begin(), LE = I->second.end();
+           LI != LE; ++LI) {
+        
+        // Remap the start index of the live range to the corresponding new
+        // number, or our best guess at what it _should_ correspond to if the
+        // original instruction has been erased.  This is either the following
+        // instruction or its predecessor.
+        unsigned offset = LI->start % InstrSlots::NUM;
+        if (OldI2MI[LI->start / InstrSlots::NUM])
+          LI->start = mi2iMap_[OldI2MI[LI->start / InstrSlots::NUM]] + offset;
+        else {
+          unsigned i = 0;
+          MachineInstr* newInstr = 0;
+          do {
+            newInstr = OldI2MI[LI->start / InstrSlots::NUM + i];
+            i++;
+          } while (!newInstr);
+          
+          if (mi2iMap_[newInstr] ==
+              MBB2IdxMap[newInstr->getParent()->getNumber()].first)
+            LI->start = mi2iMap_[newInstr];
+          else
+            LI->start = mi2iMap_[newInstr] - InstrSlots::NUM + offset;
+        }
+        
+        // Remap the ending index in the same way that we remapped the start,
+        // except for the final step where we always map to the immediately
+        // following instruction.
+        if (LI->end / InstrSlots::NUM < OldI2MI.size()) {
+          offset = LI->end % InstrSlots::NUM;
+          if (OldI2MI[LI->end / InstrSlots::NUM])
+            LI->end = mi2iMap_[OldI2MI[LI->end / InstrSlots::NUM]] + offset;
+          else {
+            unsigned i = 0;
+            MachineInstr* newInstr = 0;
+            do {
+              newInstr = OldI2MI[LI->end / InstrSlots::NUM + i];
+              i++;
+            } while (!newInstr);
+            
+            LI->end = mi2iMap_[newInstr];
+          }
+        } else {
+          LI->end = i2miMap_.size() * InstrSlots::NUM;
+        }
+        
+        // Remap the VNInfo def index, which works the same as the
+        // start indices above.
+        VNInfo* vni = LI->valno;
+        offset = vni->def % InstrSlots::NUM;
+        if (OldI2MI[vni->def / InstrSlots::NUM])
+          vni->def = mi2iMap_[OldI2MI[vni->def / InstrSlots::NUM]] + offset;
+        else {
+          unsigned i = 0;
+          MachineInstr* newInstr = 0;
+          do {
+            newInstr = OldI2MI[vni->def / InstrSlots::NUM + i];
+            i++;
+          } while (!newInstr);
+          
+          if (mi2iMap_[newInstr] ==
+              MBB2IdxMap[newInstr->getParent()->getNumber()].first)
+            vni->def = mi2iMap_[newInstr];
+          else
+            vni->def = mi2iMap_[newInstr] - InstrSlots::NUM + offset;
+        }
+        
+        // Remap the VNInfo kill indices, which works the same as
+        // the end indices above.
+        for (size_t i = 0; i < vni->kills.size(); ++i) {
+          offset = vni->kills[i] % InstrSlots::NUM;
+          if (OldI2MI[vni->kills[i] / InstrSlots::NUM])
+            vni->kills[i] = mi2iMap_[OldI2MI[vni->kills[i] / InstrSlots::NUM]] +
+                            offset;
+          else {
+            unsigned e = 0;
+            MachineInstr* newInstr = 0;
+            do {
+              newInstr = OldI2MI[vni->kills[i] / InstrSlots::NUM + e];
+              e++;
+            } while (!newInstr);
+            
+            vni->kills[i] = mi2iMap_[newInstr];
+          }
+        }
+      }
+}
+
+/// runOnMachineFunction - Register allocate the whole function
+///
+bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
+  mf_ = &fn;
+  mri_ = &mf_->getRegInfo();
+  tm_ = &fn.getTarget();
+  tri_ = tm_->getRegisterInfo();
+  tii_ = tm_->getInstrInfo();
+  lv_ = &getAnalysis<LiveVariables>();
+  allocatableRegs_ = tri_->getAllocatableSet(fn);
 
+  computeNumbering();
   computeIntervals();
 
   numIntervals += getNumIntervals();
@@ -134,8 +233,8 @@
 void LiveIntervals::print(std::ostream &O, const Module* ) const {
   O << "********** INTERVALS **********\n";
   for (const_iterator I = begin(), E = end(); I != E; ++I) {
-    I->second.print(DOUT, tri_);
-    DOUT << "\n";
+    I->second.print(O, tri_);
+    O << "\n";
   }
 
   O << "********** MACHINEINSTRS **********\n";
@@ -198,7 +297,7 @@
 
 void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
                                              MachineBasicBlock::iterator mi,
-                                             unsigned MIIdx,
+                                             unsigned MIIdx, MachineOperand& MO,
                                              LiveInterval &interval) {
   DOUT << "\t\tregister: "; DEBUG(printRegName(interval.reg));
   LiveVariables::VarInfo& vi = lv_->getVarInfo(interval.reg);
@@ -266,14 +365,11 @@
     // live interval.
     for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) {
       if (vi.AliveBlocks[i]) {
-        MachineBasicBlock *MBB = mf_->getBlockNumbered(i);
-        if (!MBB->empty()) {
-          LiveRange LR(getMBBStartIdx(i),
-                       getInstructionIndex(&MBB->back()) + InstrSlots::NUM,
-                       ValNo);
-          interval.addRange(LR);
-          DOUT << " +" << LR;
-        }
+        LiveRange LR(getMBBStartIdx(i),
+                     getMBBEndIdx(i)+1,  // MBB ends at -1.
+                     ValNo);
+        interval.addRange(LR);
+        DOUT << " +" << LR;
       }
     }
 
@@ -332,7 +428,7 @@
 
       // If this redefinition is dead, we need to add a dummy unit live
       // range covering the def slot.
-      if (mi->registerDefIsDead(interval.reg, tri_))
+      if (MO.isDead())
         interval.addRange(LiveRange(RedefIndex, RedefIndex+1, OldValNo));
 
       DOUT << " RESULT: ";
@@ -395,6 +491,7 @@
 void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB,
                                               MachineBasicBlock::iterator mi,
                                               unsigned MIIdx,
+                                              MachineOperand& MO,
                                               LiveInterval &interval,
                                               MachineInstr *CopyMI) {
   // A physical register cannot be live across basic block, so its
@@ -408,7 +505,7 @@
   // If it is not used after definition, it is considered dead at
   // the instruction defining it. Hence its interval is:
   // [defSlot(def), defSlot(def)+1)
-  if (mi->registerDefIsDead(interval.reg, tri_)) {
+  if (MO.isDead()) {
     DOUT << " dead";
     end = getDefIndex(start) + 1;
     goto exit;
@@ -456,23 +553,26 @@
 void LiveIntervals::handleRegisterDef(MachineBasicBlock *MBB,
                                       MachineBasicBlock::iterator MI,
                                       unsigned MIIdx,
-                                      unsigned reg) {
-  if (TargetRegisterInfo::isVirtualRegister(reg))
-    handleVirtualRegisterDef(MBB, MI, MIIdx, getOrCreateInterval(reg));
-  else if (allocatableRegs_[reg]) {
+                                      MachineOperand& MO) {
+  if (TargetRegisterInfo::isVirtualRegister(MO.getReg()))
+    handleVirtualRegisterDef(MBB, MI, MIIdx, MO, 
+                             getOrCreateInterval(MO.getReg()));
+  else if (allocatableRegs_[MO.getReg()]) {
     MachineInstr *CopyMI = NULL;
     unsigned SrcReg, DstReg;
     if (MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG ||
         MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG ||
         tii_->isMoveInstr(*MI, SrcReg, DstReg))
       CopyMI = MI;
-    handlePhysicalRegisterDef(MBB, MI, MIIdx, getOrCreateInterval(reg), CopyMI);
+    handlePhysicalRegisterDef(MBB, MI, MIIdx, MO, 
+                              getOrCreateInterval(MO.getReg()), CopyMI);
     // Def of a register also defines its sub-registers.
-    for (const unsigned* AS = tri_->getSubRegisters(reg); *AS; ++AS)
+    for (const unsigned* AS = tri_->getSubRegisters(MO.getReg()); *AS; ++AS)
       // If MI also modifies the sub-register explicitly, avoid processing it
       // more than once. Do not pass in TRI here so it checks for exact match.
       if (!MI->modifiesRegister(*AS))
-        handlePhysicalRegisterDef(MBB, MI, MIIdx, getOrCreateInterval(*AS), 0);
+        handlePhysicalRegisterDef(MBB, MI, MIIdx, MO, 
+                                  getOrCreateInterval(*AS), 0);
   }
 }
 
@@ -560,11 +660,13 @@
         MachineOperand &MO = MI->getOperand(i);
         // handle register defs - build intervals
         if (MO.isRegister() && MO.getReg() && MO.isDef())
-          handleRegisterDef(MBB, MI, MIIndex, MO.getReg());
+          handleRegisterDef(MBB, MI, MIIndex, MO);
       }
       
       MIIndex += InstrSlots::NUM;
     }
+    
+    if (MBB->begin() == miEnd) MIIndex += InstrSlots::NUM; // Empty MBB
   }
 }
 
@@ -782,10 +884,6 @@
 
     // Attempt to fold the memory reference into the instruction. If
     // we can do this, we don't need to insert spill code.
-    if (lv_)
-      lv_->instructionChanged(MI, fmi);
-    else
-      fmi->copyKillDeadInfo(MI, tri_);
     MachineBasicBlock &MBB = *MI->getParent();
     if (isSS && !mf_->getFrameInfo()->isImmutableObjectIndex(Slot))
       vrm.virtFolded(Reg, MI, fmi, (VirtRegMap::ModRef)MRInfo);
@@ -876,7 +974,9 @@
                  const MachineLoopInfo *loopInfo,
                  unsigned &NewVReg, unsigned ImpUse, bool &HasDef, bool &HasUse,
                  std::map<unsigned,unsigned> &MBBVRegsMap,
-                 std::vector<LiveInterval*> &NewLIs) {
+                 std::vector<LiveInterval*> &NewLIs, float &SSWeight) {
+  MachineBasicBlock *MBB = MI->getParent();
+  unsigned loopDepth = loopInfo->getLoopDepth(MBB);
   bool CanFold = false;
  RestartInstruction:
   for (unsigned i = 0; i != MI->getNumOperands(); ++i) {
@@ -945,7 +1045,14 @@
       }
     }
 
-    if (TryFold) {
+    // Update stack slot spill weight if we are splitting.
+    float Weight = getSpillWeight(HasDef, HasUse, loopDepth);
+      if (!TrySplit)
+      SSWeight += Weight;
+
+    if (!TryFold)
+      CanFold = false;
+    else {
       // Do not fold load / store here if we are splitting. We'll find an
       // optimal point to insert a load / store later.
       if (!TrySplit) {
@@ -956,15 +1063,17 @@
           HasUse = false;
           HasDef = false;
           CanFold = false;
-          if (isRemoved(MI))
+          if (isRemoved(MI)) {
+            SSWeight -= Weight;
             break;
+          }
           goto RestartInstruction;
         }
       } else {
+        // We'll try to fold it later if it's profitable.
         CanFold = canFoldMemoryOperand(MI, Ops, DefIsReMat);
       }
-    } else
-      CanFold = false;
+    }
 
     // Create a new virtual register for the spill interval.
     bool CreatedNewVReg = false;
@@ -1065,33 +1174,24 @@
   return false;
 }
 
-static const VNInfo *findDefinedVNInfo(const LiveInterval &li, unsigned DefIdx) {
-  const VNInfo *VNI = NULL;
-  for (LiveInterval::const_vni_iterator i = li.vni_begin(),
-         e = li.vni_end(); i != e; ++i)
-    if ((*i)->def == DefIdx) {
-      VNI = *i;
-      break;
-    }
-  return VNI;
-}
-
 /// RewriteInfo - Keep track of machine instrs that will be rewritten
 /// during spilling.
-struct RewriteInfo {
-  unsigned Index;
-  MachineInstr *MI;
-  bool HasUse;
-  bool HasDef;
-  RewriteInfo(unsigned i, MachineInstr *mi, bool u, bool d)
-    : Index(i), MI(mi), HasUse(u), HasDef(d) {}
-};
-
-struct RewriteInfoCompare {
-  bool operator()(const RewriteInfo &LHS, const RewriteInfo &RHS) const {
-    return LHS.Index < RHS.Index;
-  }
-};
+namespace {
+  struct RewriteInfo {
+    unsigned Index;
+    MachineInstr *MI;
+    bool HasUse;
+    bool HasDef;
+    RewriteInfo(unsigned i, MachineInstr *mi, bool u, bool d)
+      : Index(i), MI(mi), HasUse(u), HasDef(d) {}
+  };
+
+  struct RewriteInfoCompare {
+    bool operator()(const RewriteInfo &LHS, const RewriteInfo &RHS) const {
+      return LHS.Index < RHS.Index;
+    }
+  };
+}
 
 void LiveIntervals::
 rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit,
@@ -1108,7 +1208,7 @@
                     BitVector &RestoreMBBs,
                     std::map<unsigned, std::vector<SRInfo> > &RestoreIdxes,
                     std::map<unsigned,unsigned> &MBBVRegsMap,
-                    std::vector<LiveInterval*> &NewLIs) {
+                    std::vector<LiveInterval*> &NewLIs, float &SSWeight) {
   bool AllCanFold = true;
   unsigned NewVReg = 0;
   unsigned start = getBaseIndex(I->start);
@@ -1196,10 +1296,10 @@
     bool HasDef = false;
     bool HasUse = false;
     bool CanFold = rewriteInstructionForSpills(li, I->valno, TrySplit,
-                                index, end, MI, ReMatOrigDefMI, ReMatDefMI,
-                                Slot, LdSlot, isLoad, isLoadSS, DefIsReMat,
-                                CanDelete, vrm, rc, ReMatIds, loopInfo, NewVReg,
-                                ImpUse, HasDef, HasUse, MBBVRegsMap, NewLIs);
+                         index, end, MI, ReMatOrigDefMI, ReMatDefMI,
+                         Slot, LdSlot, isLoad, isLoadSS, DefIsReMat,
+                         CanDelete, vrm, rc, ReMatIds, loopInfo, NewVReg,
+                         ImpUse, HasDef, HasUse, MBBVRegsMap, NewLIs, SSWeight);
     if (!HasDef && !HasUse)
       continue;
 
@@ -1221,7 +1321,7 @@
           HasKill = anyKillInMBBAfterIdx(li, I->valno, MBB, getDefIndex(index));
         else {
           // If this is a two-address code, then this index starts a new VNInfo.
-          const VNInfo *VNI = findDefinedVNInfo(li, getDefIndex(index));
+          const VNInfo *VNI = li.findDefinedVNInfo(getDefIndex(index));
           if (VNI)
             HasKill = anyKillInMBBAfterIdx(li, VNI, MBB, getDefIndex(index));
         }
@@ -1358,11 +1458,8 @@
 
 std::vector<LiveInterval*> LiveIntervals::
 addIntervalsForSpills(const LiveInterval &li,
-                      const MachineLoopInfo *loopInfo, VirtRegMap &vrm) {
-  // Since this is called after the analysis is done we don't know if
-  // LiveVariables is available
-  lv_ = getAnalysisToUpdate<LiveVariables>();
-
+                      const MachineLoopInfo *loopInfo, VirtRegMap &vrm,
+                      float &SSWeight) {
   assert(li.weight != HUGE_VALF &&
          "attempt to spill already spilled interval!");
 
@@ -1370,6 +1467,9 @@
   li.print(DOUT, tri_);
   DOUT << '\n';
 
+  // Spill slot weight.
+  SSWeight = 0.0f;
+
   // Each bit specify whether it a spill is required in the MBB.
   BitVector SpillMBBs(mf_->getNumBlockIDs());
   std::map<unsigned, std::vector<SRInfo> > SpillIdxes;
@@ -1424,17 +1524,18 @@
                              Slot, LdSlot, isLoad, isLoadSS, DefIsReMat,
                              false, vrm, rc, ReMatIds, loopInfo,
                              SpillMBBs, SpillIdxes, RestoreMBBs, RestoreIdxes,
-                             MBBVRegsMap, NewLIs);
+                             MBBVRegsMap, NewLIs, SSWeight);
       } else {
         rewriteInstructionsForSpills(li, false, I, NULL, 0,
                              Slot, 0, false, false, false,
                              false, vrm, rc, ReMatIds, loopInfo,
                              SpillMBBs, SpillIdxes, RestoreMBBs, RestoreIdxes,
-                             MBBVRegsMap, NewLIs);
+                             MBBVRegsMap, NewLIs, SSWeight);
       }
       IsFirstRange = false;
     }
 
+    SSWeight = 0.0f;  // Already accounted for when split.
     handleSpilledImpDefs(li, vrm, rc, NewLIs);
     return NewLIs;
   }
@@ -1500,7 +1601,7 @@
                                Slot, LdSlot, isLoad, isLoadSS, DefIsReMat,
                                CanDelete, vrm, rc, ReMatIds, loopInfo,
                                SpillMBBs, SpillIdxes, RestoreMBBs, RestoreIdxes,
-                               MBBVRegsMap, NewLIs);
+                               MBBVRegsMap, NewLIs, SSWeight);
   }
 
   // Insert spills / restores if we are splitting.
@@ -1514,6 +1615,8 @@
   if (NeedStackSlot) {
     int Id = SpillMBBs.find_first();
     while (Id != -1) {
+      MachineBasicBlock *MBB = mf_->getBlockNumbered(Id);
+      unsigned loopDepth = loopInfo->getLoopDepth(MBB);
       std::vector<SRInfo> &spills = SpillIdxes[Id];
       for (unsigned i = 0, e = spills.size(); i != e; ++i) {
         int index = spills[i].index;
@@ -1564,10 +1667,16 @@
         if (!Folded) {
           LiveRange *LR = &nI.ranges[nI.ranges.size()-1];
           bool isKill = LR->end == getStoreIndex(index);
-          vrm.addSpillPoint(VReg, isKill, MI);
+          if (!MI->registerDefIsDead(nI.reg))
+            // No need to spill a dead def.
+            vrm.addSpillPoint(VReg, isKill, MI);
           if (isKill)
             AddedKill.insert(&nI);
         }
+
+        // Update spill slot weight.
+        if (!isReMat)
+          SSWeight += getSpillWeight(true, false, loopDepth);
       }
       Id = SpillMBBs.find_next(Id);
     }
@@ -1575,6 +1684,9 @@
 
   int Id = RestoreMBBs.find_first();
   while (Id != -1) {
+    MachineBasicBlock *MBB = mf_->getBlockNumbered(Id);
+    unsigned loopDepth = loopInfo->getLoopDepth(MBB);
+
     std::vector<SRInfo> &restores = RestoreIdxes[Id];
     for (unsigned i = 0, e = restores.size(); i != e; ++i) {
       int index = restores[i].index;
@@ -1582,6 +1694,7 @@
         continue;
       unsigned VReg = restores[i].vreg;
       LiveInterval &nI = getOrCreateInterval(VReg);
+      bool isReMat = vrm.isReMaterialized(VReg);
       MachineInstr *MI = getInstructionFromIndex(index);
       bool CanFold = false;
       Ops.clear();
@@ -1605,7 +1718,7 @@
       // Fold the load into the use if possible.
       bool Folded = false;
       if (CanFold && !Ops.empty()) {
-        if (!vrm.isReMaterialized(VReg))
+        if (!isReMat)
           Folded = tryFoldMemoryOperand(MI, vrm, NULL,index,Ops,true,Slot,VReg);
         else {
           MachineInstr *ReMatDefMI = vrm.getReMaterializedMI(VReg);
@@ -1633,6 +1746,10 @@
         nI.removeRange(getLoadIndex(index), getUseIndex(index)+1);
       else
         vrm.addRestorePoint(VReg, MI);
+
+      // Update spill slot weight.
+      if (!isReMat)
+        SSWeight += getSpillWeight(false, true, loopDepth);
     }
     Id = RestoreMBBs.find_next(Id);
   }
@@ -1741,3 +1858,18 @@
     }
   }
 }
+
+LiveRange LiveIntervals::addLiveRangeToEndOfBlock(unsigned reg,
+                                                   MachineInstr* startInst) {
+  LiveInterval& Interval = getOrCreateInterval(reg);
+  VNInfo* VN = Interval.getNextValue(
+            getInstructionIndex(startInst) + InstrSlots::DEF,
+            startInst, getVNInfoAllocator());
+  VN->hasPHIKill = true;
+  VN->kills.push_back(getMBBEndIdx(startInst->getParent()));
+  LiveRange LR(getInstructionIndex(startInst) + InstrSlots::DEF,
+               getMBBEndIdx(startInst->getParent()) + 1, VN);
+  Interval.addRange(LR);
+  
+  return LR;
+}

Added: llvm/branches/non-call-eh/lib/CodeGen/LiveStackAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/LiveStackAnalysis.cpp?rev=53163&view=auto

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/LiveStackAnalysis.cpp (added)
+++ llvm/branches/non-call-eh/lib/CodeGen/LiveStackAnalysis.cpp Sun Jul  6 15:45:41 2008
@@ -0,0 +1,50 @@
+//===-- LiveStackAnalysis.cpp - Live Stack Slot Analysis ------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the live stack slot analysis pass. It is analogous to
+// live interval analysis except it's analyzing liveness of stack slots rather
+// than registers.
+//
+//===----------------------------------------------------------------------===//
+
+#define DEBUG_TYPE "livestacks"
+#include "llvm/CodeGen/LiveStackAnalysis.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/Target/TargetRegisterInfo.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/ADT/Statistic.h"
+using namespace llvm;
+
+char LiveStacks::ID = 0;
+static RegisterPass<LiveStacks> X("livestacks", "Live Stack Slot Analysis");
+
+void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.setPreservesAll();
+}
+
+void LiveStacks::releaseMemory() {
+  // Release VNInfo memroy regions after all VNInfo objects are dtor'd.
+  VNInfoAllocator.Reset();
+  s2iMap.clear();
+}
+
+bool LiveStacks::runOnMachineFunction(MachineFunction &) {
+  // FIXME: No analysis is being done right now. We are relying on the
+  // register allocators to provide the information.
+  return false;
+}
+
+/// print - Implement the dump method.
+void LiveStacks::print(std::ostream &O, const Module* ) const {
+  O << "********** INTERVALS **********\n";
+  for (const_iterator I = begin(), E = end(); I != E; ++I) {
+    I->second.print(O);
+    O << "\n";
+  }
+}

Modified: llvm/branches/non-call-eh/lib/CodeGen/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/LiveVariables.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/LiveVariables.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/LiveVariables.cpp Sun Jul  6 15:45:41 2008
@@ -34,6 +34,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/alloca.h"
 #include <algorithm>
@@ -139,8 +140,23 @@
     assert(VRInfo.Kills[i]->getParent() != MBB && "entry should be at end!");
 #endif
 
-  assert(MBB != MRI->getVRegDef(reg)->getParent() &&
-         "Should have kill for defblock!");
+  // This situation can occur:
+  //
+  //     ,------.
+  //     |      |
+  //     |      v
+  //     |   t2 = phi ... t1 ...
+  //     |      |
+  //     |      v
+  //     |   t1 = ...
+  //     |  ... = ... t1 ...
+  //     |      |
+  //     `------'
+  //
+  // where there is a use in a PHI node that's a predecessor to the defining
+  // block. We don't want to mark all predecessors as having the value "alive"
+  // in this case.
+  if (MBB == MRI->getVRegDef(reg)->getParent()) return;
 
   // Add a new kill entry for this basic block. If this virtual register is
   // already marked as alive in this basic block, that means it is alive in at
@@ -372,7 +388,7 @@
 
 void LiveVariables::HandlePhysRegDef(unsigned Reg, MachineInstr *MI) {
   // What parts of the register are previously defined?
-  std::set<unsigned> Live;
+  SmallSet<unsigned, 32> Live;
   if (PhysRegDef[Reg] || PhysRegUse[Reg]) {
     Live.insert(Reg);
     for (const unsigned *SS = TRI->getSubRegisters(Reg); *SS; ++SS)
@@ -587,7 +603,7 @@
            I = MF->getRegInfo().liveout_begin(),
            E = MF->getRegInfo().liveout_end(); I != E; ++I) {
         assert(TargetRegisterInfo::isPhysicalRegister(*I) &&
-               "Cannot have a live-in virtual register!");
+               "Cannot have a live-out virtual register!");
         HandlePhysRegUse(*I, Ret);
 
         // Add live-out registers as implicit uses.
@@ -637,35 +653,12 @@
   return false;
 }
 
-/// instructionChanged - When the address of an instruction changes, this method
-/// should be called so that live variables can update its internal data
-/// structures.  This removes the records for OldMI, transfering them to the
-/// records for NewMI.
-void LiveVariables::instructionChanged(MachineInstr *OldMI,
-                                       MachineInstr *NewMI) {
-  // If the instruction defines any virtual registers, update the VarInfo,
-  // kill and dead information for the instruction.
-  for (unsigned i = 0, e = OldMI->getNumOperands(); i != e; ++i) {
-    MachineOperand &MO = OldMI->getOperand(i);
-    if (MO.isRegister() && MO.getReg() &&
-        TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
-      unsigned Reg = MO.getReg();
-      VarInfo &VI = getVarInfo(Reg);
-      if (MO.isDef()) {
-        if (MO.isDead()) {
-          MO.setIsDead(false);
-          addVirtualRegisterDead(Reg, NewMI);
-        }
-      }
-      if (MO.isKill()) {
-        MO.setIsKill(false);
-        addVirtualRegisterKilled(Reg, NewMI);
-      }
-      // If this is a kill of the value, update the VI kills list.
-      if (VI.removeKill(OldMI))
-        VI.Kills.push_back(NewMI);   // Yes, there was a kill of it
-    }
-  }
+/// replaceKillInstruction - Update register kill info by replacing a kill
+/// instruction with a new one.
+void LiveVariables::replaceKillInstruction(unsigned Reg, MachineInstr *OldMI,
+                                           MachineInstr *NewMI) {
+  VarInfo &VI = getVarInfo(Reg);
+  std::replace(VI.Kills.begin(), VI.Kills.end(), OldMI, NewMI);
 }
 
 /// removeVirtualRegistersKilled - Remove all killed info for the specified
@@ -684,22 +677,6 @@
   }
 }
 
-/// removeVirtualRegistersDead - Remove all of the dead registers for the
-/// specified instruction from the live variable information.
-void LiveVariables::removeVirtualRegistersDead(MachineInstr *MI) {
-  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
-    MachineOperand &MO = MI->getOperand(i);
-    if (MO.isRegister() && MO.isDead()) {
-      MO.setIsDead(false);
-      unsigned Reg = MO.getReg();
-      if (TargetRegisterInfo::isVirtualRegister(Reg)) {
-        bool removed = getVarInfo(Reg).removeKill(MI);
-        assert(removed && "kill not in register's VarInfo?");
-      }
-    }
-  }
-}
-
 /// analyzePHINodes - Gather information about the PHI nodes in here. In
 /// particular, we want to map the variable information of a virtual register
 /// which is used in a PHI node. We map that to the BB the vreg is coming from.

Modified: llvm/branches/non-call-eh/lib/CodeGen/LowerSubregs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/LowerSubregs.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/LowerSubregs.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/LowerSubregs.cpp Sun Jul  6 15:45:41 2008
@@ -109,8 +109,8 @@
   DOUT << "subreg: CONVERTING: " << *MI;
 
   // Insert sub-register copy
-  const TargetRegisterClass *TRC0 = TRI.getPhysicalRegisterRegClass(DstSubReg);
-  const TargetRegisterClass *TRC1 = TRI.getPhysicalRegisterRegClass(InsReg);
+  const TargetRegisterClass *TRC0= TRI.getPhysicalRegisterRegClass(DstSubReg);
+  const TargetRegisterClass *TRC1= TRI.getPhysicalRegisterRegClass(InsReg);
   TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1);
 
 #ifndef NDEBUG
@@ -149,15 +149,19 @@
 
   DOUT << "subreg: CONVERTING: " << *MI;
 
-  // Insert sub-register copy
-  const TargetRegisterClass *TRC0 = TRI.getPhysicalRegisterRegClass(DstSubReg);
-  const TargetRegisterClass *TRC1 = TRI.getPhysicalRegisterRegClass(InsReg);
-  TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1);
-
+  if (DstSubReg == InsReg) {
+    // No need to insert an identify copy instruction.
+    DOUT << "subreg: eliminated!";
+  } else {
+    // Insert sub-register copy
+    const TargetRegisterClass *TRC0= TRI.getPhysicalRegisterRegClass(DstSubReg);
+    const TargetRegisterClass *TRC1= TRI.getPhysicalRegisterRegClass(InsReg);
+    TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1);
 #ifndef NDEBUG
-  MachineBasicBlock::iterator dMI = MI;
-  DOUT << "subreg: " << *(--dMI);
+    MachineBasicBlock::iterator dMI = MI;
+    DOUT << "subreg: " << *(--dMI);
 #endif
+  }
 
   DOUT << "\n";
   MBB->remove(MI);

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachOWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachOWriter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachOWriter.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachOWriter.cpp Sun Jul  6 15:45:41 2008
@@ -403,7 +403,8 @@
     // If this global is part of the common block, add it now.  Variables are
     // part of the common block if they are zero initialized and allowed to be
     // merged with other symbols.
-    if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage()) {
+    if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() ||
+        GV->hasCommonLinkage()) {
       MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), MachOSym::NO_SECT,TM);
       // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in
       // bytes of the symbol.
@@ -839,7 +840,7 @@
         abort();
         break;
       }
-    } else if (PC->getType()->isFirstClassType()) {
+    } else if (PC->getType()->isSingleValueType()) {
       unsigned char *ptr = (unsigned char *)PA;
       switch (PC->getType()->getTypeID()) {
       case Type::IntegerTyID: {
@@ -951,6 +952,7 @@
     break;
   case GlobalValue::WeakLinkage:
   case GlobalValue::LinkOnceLinkage:
+  case GlobalValue::CommonLinkage:
     assert(!isa<Function>(gv) && "Unexpected linkage type for Function!");
   case GlobalValue::ExternalLinkage:
     GVName = TAI->getGlobalPrefix() + name;

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineBasicBlock.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineBasicBlock.cpp Sun Jul  6 15:45:41 2008
@@ -205,6 +205,11 @@
   LiveIns.erase(I);
 }
 
+bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
+  const_livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
+  return I != livein_end();
+}
+
 void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
   MachineFunction::BasicBlockListType &BBList =getParent()->getBasicBlockList();
   getParent()->getBasicBlockList().splice(NewAfter, BBList, this);
@@ -247,6 +252,19 @@
   Predecessors.erase(I);
 }
 
+void MachineBasicBlock::transferSuccessors(MachineBasicBlock *fromMBB)
+{
+  if (this == fromMBB)
+    return;
+  
+  for(MachineBasicBlock::succ_iterator iter = fromMBB->succ_begin(), 
+      end = fromMBB->succ_end(); iter != end; ++iter) {
+      addSuccessor(*iter);
+  }
+  while(!fromMBB->succ_empty())
+    fromMBB->removeSuccessor(fromMBB->succ_begin());
+}
+
 bool MachineBasicBlock::isSuccessor(MachineBasicBlock *MBB) const {
   std::vector<MachineBasicBlock *>::const_iterator I =
     std::find(Successors.begin(), Successors.end(), MBB);

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineDominators.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineDominators.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineDominators.cpp Sun Jul  6 15:45:41 2008
@@ -22,9 +22,7 @@
 
 char MachineDominatorTree::ID = 0;
 
-namespace {
-  RegisterPass<MachineDominatorTree>
-  E("machinedomtree", "MachineDominator Tree Construction", true);
-}
+static RegisterPass<MachineDominatorTree>
+E("machinedomtree", "MachineDominator Tree Construction", true);
 
-const PassInfo *llvm::MachineDominatorsID = E.getPassInfo();
+const PassInfo *const llvm::MachineDominatorsID = &E;

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineInstr.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineInstr.cpp Sun Jul  6 15:45:41 2008
@@ -523,10 +523,18 @@
 }
 
 
+/// isLabel - Returns true if the MachineInstr represents a label.
+///
+bool MachineInstr::isLabel() const {
+  return getOpcode() == TargetInstrInfo::DBG_LABEL ||
+         getOpcode() == TargetInstrInfo::EH_LABEL ||
+         getOpcode() == TargetInstrInfo::GC_LABEL;
+}
+
 /// isDebugLabel - Returns true if the MachineInstr represents a debug label.
 ///
 bool MachineInstr::isDebugLabel() const {
-  return getOpcode() == TargetInstrInfo::LABEL && getOperand(1).getImm() == 0;
+  return getOpcode() == TargetInstrInfo::DBG_LABEL;
 }
 
 /// findRegisterUseOperandIdx() - Returns the MachineOperand that is a use of
@@ -553,8 +561,9 @@
 }
   
 /// findRegisterDefOperandIdx() - Returns the operand index that is a def of
-/// the specific register or -1 if it is not found. It further tightening
-  /// the search criteria to a def that is dead the register if isDead is true.
+/// the specified register or -1 if it is not found. If isDead is true, defs
+/// that are not dead are skipped. If TargetRegisterInfo is non-null, then it
+/// also checks if there is a def of a super-register.
 int MachineInstr::findRegisterDefOperandIdx(unsigned Reg, bool isDead,
                                           const TargetRegisterInfo *TRI) const {
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
@@ -638,9 +647,9 @@
   }
 }
 
-/// isSafeToMove - Return true if it is safe to this instruction. If SawStore
-/// true, it means there is a store (or call) between the instruction the
-/// localtion and its intended destination.
+/// isSafeToMove - Return true if it is safe to move this instruction. If
+/// SawStore is set to true, it means that there is a store (or call) between
+/// the instruction's location and its intended destination.
 bool MachineInstr::isSafeToMove(const TargetInstrInfo *TII, bool &SawStore) {
   // Ignore stuff that we obviously can't move.
   if (TID->mayStore() || TID->isCall()) {
@@ -729,7 +738,7 @@
                                      const TargetRegisterInfo *RegInfo,
                                      bool AddIfNotFound) {
   bool isPhysReg = TargetRegisterInfo::isPhysicalRegister(IncomingReg);
-  bool Found = false;
+  bool hasAliases = isPhysReg && RegInfo->getAliasSet(IncomingReg);
   SmallVector<unsigned,4> DeadOps;
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     MachineOperand &MO = getOperand(i);
@@ -740,15 +749,15 @@
       continue;
 
     if (Reg == IncomingReg) {
-      if (!Found)  // One kill of reg per instruction.
-        MO.setIsKill();
-      Found = true;
-    } else if (isPhysReg && MO.isKill() &&
-               TargetRegisterInfo::isPhysicalRegister(Reg)) {
+      MO.setIsKill();
+      return true;
+    }
+    if (hasAliases && MO.isKill() &&
+        TargetRegisterInfo::isPhysicalRegister(Reg)) {
       // A super-register kill already exists.
       if (RegInfo->isSuperRegister(IncomingReg, Reg))
-        Found = true;
-      else if (RegInfo->isSubRegister(IncomingReg, Reg))
+        return true;
+      if (RegInfo->isSubRegister(IncomingReg, Reg))
         DeadOps.push_back(i);
     }
   }
@@ -765,21 +774,21 @@
 
   // If not found, this means an alias of one of the operands is killed. Add a
   // new implicit operand if required.
-  if (!Found && AddIfNotFound) {
+  if (AddIfNotFound) {
     addOperand(MachineOperand::CreateReg(IncomingReg,
                                          false /*IsDef*/,
                                          true  /*IsImp*/,
                                          true  /*IsKill*/));
     return true;
   }
-  return Found;
+  return false;
 }
 
 bool MachineInstr::addRegisterDead(unsigned IncomingReg,
                                    const TargetRegisterInfo *RegInfo,
                                    bool AddIfNotFound) {
   bool isPhysReg = TargetRegisterInfo::isPhysicalRegister(IncomingReg);
-  bool Found = false;
+  bool hasAliases = isPhysReg && RegInfo->getAliasSet(IncomingReg);
   SmallVector<unsigned,4> DeadOps;
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     MachineOperand &MO = getOperand(i);
@@ -788,13 +797,14 @@
     unsigned Reg = MO.getReg();
     if (Reg == IncomingReg) {
       MO.setIsDead();
-      Found = true;
-    } else if (isPhysReg && MO.isDead() &&
+      return true;
+    }
+    if (hasAliases && MO.isDead() &&
         TargetRegisterInfo::isPhysicalRegister(Reg)) {
       // There exists a super-register that's marked dead.
       if (RegInfo->isSuperRegister(IncomingReg, Reg))
-        Found = true;
-      else if (RegInfo->isSubRegister(IncomingReg, Reg))
+        return true;
+      if (RegInfo->isSubRegister(IncomingReg, Reg))
         DeadOps.push_back(i);
     }
   }
@@ -811,35 +821,11 @@
 
   // If not found, this means an alias of one of the operand is dead. Add a
   // new implicit operand.
-  if (!Found && AddIfNotFound) {
+  if (AddIfNotFound) {
     addOperand(MachineOperand::CreateReg(IncomingReg, true/*IsDef*/,
                                          true/*IsImp*/,false/*IsKill*/,
                                          true/*IsDead*/));
     return true;
   }
-  return Found;
-}
-
-/// copyKillDeadInfo - copies killed/dead information from one instr to another
-void MachineInstr::copyKillDeadInfo(MachineInstr *OldMI,
-                                    const TargetRegisterInfo *RegInfo) {
-  // If the instruction defines any virtual registers, update the VarInfo,
-  // kill and dead information for the instruction.
-  for (unsigned i = 0, e = OldMI->getNumOperands(); i != e; ++i) {
-    MachineOperand &MO = OldMI->getOperand(i);
-    if (MO.isRegister() && MO.getReg() &&
-        TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
-      unsigned Reg = MO.getReg();
-      if (MO.isDef()) {
-        if (MO.isDead()) {
-          MO.setIsDead(false);
-          addRegisterDead(Reg, RegInfo);
-        }
-      }
-      if (MO.isKill()) {
-        MO.setIsKill(false);
-        addRegisterKilled(Reg, RegInfo);
-      }
-    }
-  }
+  return false;
 }

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineLICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineLICM.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineLICM.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineLICM.cpp Sun Jul  6 15:45:41 2008
@@ -34,16 +34,16 @@
   class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass {
     const TargetMachine   *TM;
     const TargetInstrInfo *TII;
-    MachineFunction       *CurMF; // Current MachineFunction
+    MachineFunction       *CurMF;  // Current MachineFunction
 
     // Various analyses that we use...
-    MachineLoopInfo      *LI;   // Current MachineLoopInfo
-    MachineDominatorTree *DT;   // Machine dominator tree for the current Loop
+    MachineLoopInfo      *LI;      // Current MachineLoopInfo
+    MachineDominatorTree *DT;      // Machine dominator tree for the cur loop
     MachineRegisterInfo  *RegInfo; // Machine register information
 
     // State that is updated as we process loops
-    bool         Changed;       // True if a loop is changed.
-    MachineLoop *CurLoop;       // The current loop we are working on.
+    bool         Changed;          // True if a loop is changed.
+    MachineLoop *CurLoop;          // The current loop we are working on.
   public:
     static char ID; // Pass identification, replacement for typeid
     MachineLICM() : MachineFunctionPass((intptr_t)&ID) {}
@@ -150,12 +150,12 @@
     ///
     void Hoist(MachineInstr &MI);
   };
-
-  char MachineLICM::ID = 0;
-  RegisterPass<MachineLICM> X("machine-licm",
-                              "Machine Loop Invariant Code Motion");
 } // end anonymous namespace
 
+char MachineLICM::ID = 0;
+static RegisterPass<MachineLICM>
+X("machine-licm", "Machine Loop Invariant Code Motion");
+
 FunctionPass *llvm::createMachineLICMPass() { return new MachineLICM(); }
 
 /// Hoist expressions out of the specified loop. Note, alias info for inner loop
@@ -233,15 +233,14 @@
     return false;
   
   if (TID.mayLoad()) {
-    // Okay, this instruction does a load.  As a refinement, allow the target
-    // to decide whether the loaded value is actually a constant.  If so, we
-    // can actually use it as a load.
-    if (!TII->isInvariantLoad(&I)) {
+    // Okay, this instruction does a load. As a refinement, we allow the target
+    // to decide whether the loaded value is actually a constant. If so, we can
+    // actually use it as a load.
+    if (!TII->isInvariantLoad(&I))
       // FIXME: we should be able to sink loads with no other side effects if
       // there is nothing that can change memory from here until the end of
-      // block.  This is a trivial form of alias analysis.
+      // block. This is a trivial form of alias analysis.
       return false;
-    }
   }
 
   DEBUG({
@@ -263,12 +262,9 @@
              *ImpDefs; ++ImpDefs)
           DOUT << "      -> " << TRI->getName(*ImpDefs) << "\n";
       }
-
-        //if (TII->hasUnmodelledSideEffects(&I))
-        //DOUT << "  * Instruction has side effects.\n";
     });
 
-  // The instruction is loop invariant if all of its operands are loop-invariant
+  // The instruction is loop invariant if all of its operands are.
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
     const MachineOperand &MO = I.getOperand(i);
 
@@ -282,7 +278,8 @@
     if (TargetRegisterInfo::isPhysicalRegister(Reg))
       return false;
 
-    assert(RegInfo->getVRegDef(Reg)&&"Machine instr not mapped for this vreg?");
+    assert(RegInfo->getVRegDef(Reg) &&
+           "Machine instr not mapped for this vreg?!");
 
     // If the loop contains the definition of an operand, then the instruction
     // isn't loop invariant.
@@ -294,8 +291,8 @@
   return true;
 }
 
-/// Hoist - When an instruction is found to only use loop invariant operands
-/// that is safe to hoist, this instruction is called to do the dirty work.
+/// Hoist - When an instruction is found to use only loop invariant operands
+/// that are safe to hoist, this instruction is called to do the dirty work.
 ///
 void MachineLICM::Hoist(MachineInstr &MI) {
   if (!IsLoopInvariantInst(MI)) return;

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineLoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineLoopInfo.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineLoopInfo.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineLoopInfo.cpp Sun Jul  6 15:45:41 2008
@@ -23,12 +23,10 @@
 TEMPLATE_INSTANTIATION(class LoopInfoBase<MachineBasicBlock>);
 
 char MachineLoopInfo::ID = 0;
-namespace {
-  RegisterPass<MachineLoopInfo>
-  X("machine-loops", "Machine Natural Loop Construction", true);
-}
+static RegisterPass<MachineLoopInfo>
+X("machine-loops", "Machine Natural Loop Construction", true);
 
-const PassInfo *llvm::MachineLoopInfoID = X.getPassInfo();
+const PassInfo *const llvm::MachineLoopInfoID = &X;
 
 bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) {
   releaseMemory();
@@ -40,6 +38,3 @@
   AU.setPreservesAll();
   AU.addRequired<MachineDominatorTree>();
 }
-
-// Ensure this file gets linked when MachineLoopInfo.h is used.
-DEFINING_FILE_FOR(MachineLoopInfo)

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineModuleInfo.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineModuleInfo.cpp Sun Jul  6 15:45:41 2008
@@ -10,6 +10,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 
 #include "llvm/Constants.h"
+#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineLocation.h"
@@ -27,9 +28,8 @@
 using namespace llvm::dwarf;
 
 // Handle the Pass registration stuff necessary to use TargetData's.
-namespace {
-  RegisterPass<MachineModuleInfo> X("machinemoduleinfo", "Module Information");
-}
+static RegisterPass<MachineModuleInfo>
+X("machinemoduleinfo", "Module Information");
 char MachineModuleInfo::ID = 0;
 
 //===----------------------------------------------------------------------===//
@@ -52,10 +52,9 @@
 
 /// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
 /// named GlobalVariable.
-static std::vector<GlobalVariable*>
-getGlobalVariablesUsing(Module &M, const std::string &RootName) {
-  std::vector<GlobalVariable*> Result;  // GlobalVariables matching criteria.
-  
+static void
+getGlobalVariablesUsing(Module &M, const std::string &RootName,
+                        std::vector<GlobalVariable*> &Result) {
   std::vector<const Type*> FieldTypes;
   FieldTypes.push_back(Type::Int32Ty);
   FieldTypes.push_back(Type::Int32Ty);
@@ -65,11 +64,8 @@
                                                 StructType::get(FieldTypes));
 
   // If present and linkonce then scan for users.
-  if (UseRoot && UseRoot->hasLinkOnceLinkage()) {
+  if (UseRoot && UseRoot->hasLinkOnceLinkage())
     getGlobalVariablesUsing(UseRoot, Result);
-  }
-  
-  return Result;
 }
   
 /// isStringValue - Return true if the given value can be coerced to a string.
@@ -160,6 +156,8 @@
   DD->ApplyToFields(this);
 }
 
+namespace {
+
 //===----------------------------------------------------------------------===//
 /// DICountVisitor - This DIVisitor counts all the fields in the supplied debug
 /// the supplied DebugInfoDesc.
@@ -199,10 +197,7 @@
 
 public:
   DIDeserializeVisitor(DIDeserializer &D, GlobalVariable *GV)
-  : DIVisitor()
-  , DR(D)
-  , I(0)
-  , CI(cast<ConstantStruct>(GV->getInitializer()))
+    : DIVisitor(), DR(D), I(0), CI(cast<ConstantStruct>(GV->getInitializer()))
   {}
   
   /// Apply - Set the value of each of the fields.
@@ -229,7 +224,9 @@
   }
   virtual void Apply(std::string &Field) {
     Constant *C = CI->getOperand(I++);
-    Field = C->getStringValue();
+    // Fills in the string if it succeeds
+    if (!GetConstantStringInfo(C, Field))
+      Field.clear();
   }
   virtual void Apply(DebugInfoDesc *&Field) {
     Constant *C = CI->getOperand(I++);
@@ -293,7 +290,7 @@
     Elements.push_back(ConstantInt::get(Type::Int1Ty, Field));
   }
   virtual void Apply(std::string &Field) {
-      Elements.push_back(SR.getString(Field));
+    Elements.push_back(SR.getString(Field));
   }
   virtual void Apply(DebugInfoDesc *&Field) {
     GlobalVariable *GV = NULL;
@@ -479,6 +476,7 @@
   }
 };
 
+}
 
 //===----------------------------------------------------------------------===//
 
@@ -1284,14 +1282,14 @@
 ///
 const PointerType *DISerializer::getEmptyStructPtrType() {
   // If not already defined.
-  if (!EmptyStructPtrTy) {
-    // Construct the empty structure type.
-    const StructType *EmptyStructTy =
-                                    StructType::get(std::vector<const Type*>());
-    // Construct the pointer to empty structure type.
-    EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
-  }
-  
+  if (EmptyStructPtrTy) return EmptyStructPtrTy;
+
+  // Construct the pointer to empty structure type.
+  const StructType *EmptyStructTy =
+    StructType::get(std::vector<const Type*>());
+
+  // Construct the pointer to empty structure type.
+  EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
   return EmptyStructPtrTy;
 }
 
@@ -1323,23 +1321,28 @@
 ///
 Constant *DISerializer::getString(const std::string &String) {
   // Check string cache for previous edition.
-  Constant *&Slot = StringCache[String];
+  Constant *&Slot = StringCache[String.c_str()];
+
   // Return Constant if previously defined.
   if (Slot) return Slot;
+
   // If empty string then use a sbyte* null instead.
   if (String.empty()) {
     Slot = ConstantPointerNull::get(getStrPtrType());
   } else {
     // Construct string as an llvm constant.
     Constant *ConstStr = ConstantArray::get(String);
+
     // Otherwise create and return a new string global.
     GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
                                                GlobalVariable::InternalLinkage,
                                                ConstStr, ".str", M);
     StrGV->setSection("llvm.metadata");
+
     // Convert to generic string pointer.
     Slot = ConstantExpr::getBitCast(StrGV, getStrPtrType());
   }
+
   return Slot;
   
 }
@@ -1369,7 +1372,7 @@
   // Add fields.
   DISerializeVisitor SRAM(*this, Elements);
   SRAM.ApplyToFields(DD);
-  
+
   // Set the globals initializer.
   GV->setInitializer(ConstantStruct::get(Ty, Elements));
   
@@ -1586,7 +1589,8 @@
 /// SetupCompileUnits - Set up the unique vector of compile units.
 ///
 void MachineModuleInfo::SetupCompileUnits(Module &M) {
-  std::vector<CompileUnitDesc *>CU = getAnchoredDescriptors<CompileUnitDesc>(M);
+  std::vector<CompileUnitDesc *> CU;
+  getAnchoredDescriptors<CompileUnitDesc>(M, CU);
   
   for (unsigned i = 0, N = CU.size(); i < N; i++) {
     CompileUnits.insert(CU[i]);
@@ -1601,10 +1605,11 @@
 
 /// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
 /// named GlobalVariable.
-std::vector<GlobalVariable*>
+void
 MachineModuleInfo::getGlobalVariablesUsing(Module &M,
-                                           const std::string &RootName) {
-  return ::getGlobalVariablesUsing(M, RootName);
+                                           const std::string &RootName,
+                                           std::vector<GlobalVariable*>&Result){
+  return ::getGlobalVariablesUsing(M, RootName, Result);
 }
 
 /// RecordSourceLine - Records location information and associates it with a

Modified: llvm/branches/non-call-eh/lib/CodeGen/MachineSink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/MachineSink.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/MachineSink.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/MachineSink.cpp Sun Jul  6 15:45:41 2008
@@ -50,10 +50,11 @@
     bool SinkInstruction(MachineInstr *MI, bool &SawStore);
     bool AllUsesDominatedByBlock(unsigned Reg, MachineBasicBlock *MBB) const;
   };
-  
-  char MachineSinking::ID = 0;
-  RegisterPass<MachineSinking> X("machine-sink", "Machine code sinking");
 } // end anonymous namespace
+  
+char MachineSinking::ID = 0;
+static RegisterPass<MachineSinking>
+X("machine-sink", "Machine code sinking");
 
 FunctionPass *llvm::createMachineSinkingPass() { return new MachineSinking(); }
 

Modified: llvm/branches/non-call-eh/lib/CodeGen/OcamlCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/OcamlCollector.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/OcamlCollector.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/OcamlCollector.cpp Sun Jul  6 15:45:41 2008
@@ -35,11 +35,11 @@
                         const TargetAsmInfo &TAI);
   };
   
-  CollectorRegistry::Add<OcamlCollector>
-  X("ocaml", "ocaml 3.10-compatible collector");
-  
 }
 
+static CollectorRegistry::Add<OcamlCollector>
+X("ocaml", "ocaml 3.10-compatible collector");
+
 // -----------------------------------------------------------------------------
 
 static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP,

Modified: llvm/branches/non-call-eh/lib/CodeGen/PHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/PHIElimination.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/PHIElimination.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/PHIElimination.cpp Sun Jul  6 15:45:41 2008
@@ -73,13 +73,13 @@
     // Defs of PHI sources which are implicit_def.
     SmallPtrSet<MachineInstr*, 4> ImpDefs;
   };
-
-  char PNE::ID = 0;
-  RegisterPass<PNE> X("phi-node-elimination",
-                      "Eliminate PHI nodes for register allocation");
 }
 
-const PassInfo *llvm::PHIEliminationID = X.getPassInfo();
+char PNE::ID = 0;
+static RegisterPass<PNE>
+X("phi-node-elimination", "Eliminate PHI nodes for register allocation");
+
+const PassInfo *const llvm::PHIEliminationID = &X;
 
 bool PNE::runOnMachineFunction(MachineFunction &Fn) {
   MRI = &Fn.getRegInfo();
@@ -97,7 +97,7 @@
          E = ImpDefs.end(); I != E; ++I) {
     MachineInstr *DefMI = *I;
     unsigned DefReg = DefMI->getOperand(0).getReg();
-    if (MRI->use_begin(DefReg) == MRI->use_end())
+    if (MRI->use_empty(DefReg))
       DefMI->eraseFromParent();
   }
 
@@ -127,17 +127,24 @@
   return true;
 }
 
-static bool isSourceDefinedByImplicitDef(MachineInstr *MPhi, unsigned SrcIdx,
-                                         MachineRegisterInfo  *MRI) {
-  unsigned SrcReg = MPhi->getOperand(SrcIdx*2+1).getReg();
-  MachineInstr *DefMI = MRI->getVRegDef(SrcReg);
-  return DefMI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF;
+/// isSourceDefinedByImplicitDef - Return true if all sources of the phi node
+/// are implicit_def's.
+static bool isSourceDefinedByImplicitDef(const MachineInstr *MPhi,
+                                         const MachineRegisterInfo *MRI) {
+  for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2) {
+    unsigned SrcReg = MPhi->getOperand(i).getReg();
+    const MachineInstr *DefMI = MRI->getVRegDef(SrcReg);
+    if (!DefMI || DefMI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF)
+      return false;
+  }
+  return true;
 }
 
 /// LowerAtomicPHINode - Lower the PHI node at the top of the specified block,
 /// under the assuption that it needs to be lowered in a way that supports
 /// atomic execution of PHIs.  This lowering method is always correct all of the
 /// time.
+/// 
 void PNE::LowerAtomicPHINode(MachineBasicBlock &MBB,
                              MachineBasicBlock::iterator AfterPHIsIt) {
   // Unlink the PHI node from the basic block, but don't delete the PHI yet.
@@ -145,117 +152,116 @@
 
   unsigned NumSrcs = (MPhi->getNumOperands() - 1) / 2;
   unsigned DestReg = MPhi->getOperand(0).getReg();
+  bool isDead = MPhi->getOperand(0).isDead();
 
   // Create a new register for the incoming PHI arguments.
   MachineFunction &MF = *MBB.getParent();
   const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg);
-  unsigned IncomingReg = MF.getRegInfo().createVirtualRegister(RC);
+  unsigned IncomingReg = 0;
 
-  // Insert a register to register copy in the top of the current block (but
+  // Insert a register to register copy at the top of the current block (but
   // after any remaining phi nodes) which copies the new incoming register
   // into the phi node destination.
-  //
   const TargetInstrInfo *TII = MF.getTarget().getInstrInfo();
-  if (NumSrcs == 1 && isSourceDefinedByImplicitDef(MPhi, 0, MRI))
-    // If the only source of a PHI node is an implicit_def, just emit an
+  if (isSourceDefinedByImplicitDef(MPhi, MRI))
+    // If all sources of a PHI node are implicit_def, just emit an
     // implicit_def instead of a copy.
-    BuildMI(MBB, AfterPHIsIt, TII->get(TargetInstrInfo::IMPLICIT_DEF), DestReg);
-  else
+    BuildMI(MBB, AfterPHIsIt,
+            TII->get(TargetInstrInfo::IMPLICIT_DEF), DestReg);
+  else {
+    IncomingReg = MF.getRegInfo().createVirtualRegister(RC);
     TII->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC, RC);
+  }
 
-  // Update live variable information if there is any...
+  // Update live variable information if there is any.
   LiveVariables *LV = getAnalysisToUpdate<LiveVariables>();
   if (LV) {
     MachineInstr *PHICopy = prior(AfterPHIsIt);
 
-    // Increment use count of the newly created virtual register.
-    LV->getVarInfo(IncomingReg).NumUses++;
+    if (IncomingReg) {
+      // Increment use count of the newly created virtual register.
+      LV->getVarInfo(IncomingReg).NumUses++;
+
+      // Add information to LiveVariables to know that the incoming value is
+      // killed.  Note that because the value is defined in several places (once
+      // each for each incoming block), the "def" block and instruction fields
+      // for the VarInfo is not filled in.
+      LV->addVirtualRegisterKilled(IncomingReg, PHICopy);
 
-    // Add information to LiveVariables to know that the incoming value is
-    // killed.  Note that because the value is defined in several places (once
-    // each for each incoming block), the "def" block and instruction fields
-    // for the VarInfo is not filled in.
-    //
-    LV->addVirtualRegisterKilled(IncomingReg, PHICopy);
+      LV->getVarInfo(IncomingReg).UsedBlocks[MBB.getNumber()] = true;
+    }
 
-    // Since we are going to be deleting the PHI node, if it is the last use
-    // of any registers, or if the value itself is dead, we need to move this
+    // Since we are going to be deleting the PHI node, if it is the last use of
+    // any registers, or if the value itself is dead, we need to move this
     // information over to the new copy we just inserted.
-    //
     LV->removeVirtualRegistersKilled(MPhi);
 
     // If the result is dead, update LV.
-    if (MPhi->registerDefIsDead(DestReg)) {
+    if (isDead) {
       LV->addVirtualRegisterDead(DestReg, PHICopy);
-      LV->removeVirtualRegistersDead(MPhi);
+      LV->removeVirtualRegisterDead(DestReg, MPhi);
     }
-
-    LV->getVarInfo(IncomingReg).UsedBlocks[MBB.getNumber()] = true;
   }
 
-  // Adjust the VRegPHIUseCount map to account for the removal of this PHI
-  // node.
+  // Adjust the VRegPHIUseCount map to account for the removal of this PHI node.
   for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2)
     --VRegPHIUseCount[BBVRegPair(MPhi->getOperand(i + 1).getMBB(),
                                  MPhi->getOperand(i).getReg())];
 
-  // Now loop over all of the incoming arguments, changing them to copy into
-  // the IncomingReg register in the corresponding predecessor basic block.
-  //
+  // Now loop over all of the incoming arguments, changing them to copy into the
+  // IncomingReg register in the corresponding predecessor basic block.
   SmallPtrSet<MachineBasicBlock*, 8> MBBsInsertedInto;
   for (int i = NumSrcs - 1; i >= 0; --i) {
     unsigned SrcReg = MPhi->getOperand(i*2+1).getReg();
     assert(TargetRegisterInfo::isVirtualRegister(SrcReg) &&
            "Machine PHI Operands must all be virtual registers!");
 
-    // If source is defined by an implicit def, there is no need to insert
-    // a copy unless it's the only source.
+    // If source is defined by an implicit def, there is no need to insert a
+    // copy.
     MachineInstr *DefMI = MRI->getVRegDef(SrcReg);
     if (DefMI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) {
       ImpDefs.insert(DefMI);
       continue;
     }
 
-    // Get the MachineBasicBlock equivalent of the BasicBlock that is the
-    // source path the PHI.
+    // Get the MachineBasicBlock equivalent of the BasicBlock that is the source
+    // path the PHI.
     MachineBasicBlock &opBlock = *MPhi->getOperand(i*2+2).getMBB();
 
     // Check to make sure we haven't already emitted the copy for this block.
-    // This can happen because PHI nodes may have multiple entries for the
-    // same basic block.
+    // This can happen because PHI nodes may have multiple entries for the same
+    // basic block.
     if (!MBBsInsertedInto.insert(&opBlock))
       continue;  // If the copy has already been emitted, we're done.
  
-    // Find a safe location to insert the copy, this may be the first
-    // terminator in the block (or end()).
+    // Find a safe location to insert the copy, this may be the first terminator
+    // in the block (or end()).
     MachineBasicBlock::iterator InsertPos = opBlock.getFirstTerminator();
-    
+
     // Insert the copy.
     TII->copyRegToReg(opBlock, InsertPos, IncomingReg, SrcReg, RC, RC);
 
     // Now update live variable information if we have it.  Otherwise we're done
     if (!LV) continue;
     
-    // We want to be able to insert a kill of the register if this PHI
-    // (aka, the copy we just inserted) is the last use of the source
-    // value.  Live variable analysis conservatively handles this by
-    // saying that the value is live until the end of the block the PHI
-    // entry lives in.  If the value really is dead at the PHI copy, there
-    // will be no successor blocks which have the value live-in.
-    //
-    // Check to see if the copy is the last use, and if so, update the
-    // live variables information so that it knows the copy source
-    // instruction kills the incoming value.
+    // We want to be able to insert a kill of the register if this PHI (aka, the
+    // copy we just inserted) is the last use of the source value.  Live
+    // variable analysis conservatively handles this by saying that the value is
+    // live until the end of the block the PHI entry lives in.  If the value
+    // really is dead at the PHI copy, there will be no successor blocks which
+    // have the value live-in.
     //
+    // Check to see if the copy is the last use, and if so, update the live
+    // variables information so that it knows the copy source instruction kills
+    // the incoming value.
     LiveVariables::VarInfo &InRegVI = LV->getVarInfo(SrcReg);
     InRegVI.UsedBlocks[opBlock.getNumber()] = true;
 
-    // Loop over all of the successors of the basic block, checking to see
-    // if the value is either live in the block, or if it is killed in the
-    // block.  Also check to see if this register is in use by another PHI
-    // node which has not yet been eliminated.  If so, it will be killed
-    // at an appropriate point later.
-    //
+    // Loop over all of the successors of the basic block, checking to see if
+    // the value is either live in the block, or if it is killed in the block.
+    // Also check to see if this register is in use by another PHI node which
+    // has not yet been eliminated.  If so, it will be killed at an appropriate
+    // point later.
 
     // Is it used by any PHI instructions in this block?
     bool ValueIsLive = VRegPHIUseCount[BBVRegPair(&opBlock, SrcReg)] != 0;
@@ -312,12 +318,11 @@
       }
     }        
 
-    // Okay, if we now know that the value is not live out of the block,
-    // we can add a kill marker in this block saying that it kills the incoming
-    // value!
+    // Okay, if we now know that the value is not live out of the block, we can
+    // add a kill marker in this block saying that it kills the incoming value!
     if (!ValueIsLive) {
       // In our final twist, we have to decide which instruction kills the
-      // register.  In most cases this is the copy, however, the first 
+      // register.  In most cases this is the copy, however, the first
       // terminator instruction at the end of the block may also use the value.
       // In this case, we should mark *it* as being the killing block, not the
       // copy.

Modified: llvm/branches/non-call-eh/lib/CodeGen/Passes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/Passes.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/Passes.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/Passes.cpp Sun Jul  6 15:45:41 2008
@@ -30,13 +30,11 @@
 /// RegAlloc command line options.
 ///
 //===---------------------------------------------------------------------===//
-namespace {
-  cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
-          RegisterPassParser<RegisterRegAlloc> >
-  RegAlloc("regalloc",
-           cl::init(&createLinearScanRegisterAllocator),
-           cl::desc("Register allocator to use: (default = linearscan)")); 
-}
+static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
+               RegisterPassParser<RegisterRegAlloc> >
+RegAlloc("regalloc",
+         cl::init(&createLinearScanRegisterAllocator),
+         cl::desc("Register allocator to use: (default = linearscan)")); 
 
 
 //===---------------------------------------------------------------------===//

Modified: llvm/branches/non-call-eh/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/PrologEpilogInserter.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/PrologEpilogInserter.cpp Sun Jul  6 15:45:41 2008
@@ -68,7 +68,7 @@
 
       // Allow the target machine to make final modifications to the function
       // before the frame layout is finalized.
-      Fn.getTarget().getRegisterInfo()->processFunctionBeforeFrameFinalized(Fn);
+      TRI->processFunctionBeforeFrameFinalized(Fn);
 
       // Calculate actual frame offsets for all of the abstract stack objects...
       calculateFrameObjectOffsets(Fn);
@@ -313,7 +313,7 @@
   // Loop over all of the stack objects, assigning sequential addresses...
   MachineFrameInfo *FFI = Fn.getFrameInfo();
 
-  unsigned MaxAlign = 0;
+  unsigned MaxAlign = FFI->getMaxAlignment();
 
   // Start at the beginning of the local area.
   // The Offset is the distance from the stack top in the direction
@@ -362,7 +362,8 @@
       FFI->setObjectOffset(i, -Offset);        // Set the computed offset
     }
   } else {
-    for (unsigned i = MaxCSFrameIndex; i >= MinCSFrameIndex; --i) {
+    int MaxCSFI = MaxCSFrameIndex, MinCSFI = MinCSFrameIndex;
+    for (int i = MaxCSFI; i >= MinCSFI ; --i) {
       unsigned Align = FFI->getObjectAlignment(i);
       // If the alignment of this object is greater than that of the stack, then
       // increase the stack alignment to match.
@@ -458,15 +459,20 @@
   // Round up the size to a multiple of the alignment, but only if there are
   // calls or alloca's in the function.  This ensures that any calls to
   // subroutines have their stack frames suitable aligned.
+  // Also do this if we need runtime alignment of the stack.  In this case
+  // offsets will be relative to SP not FP; round up the stack size so this
+  // works.
   if (!RegInfo->targetHandlesStackFrameRounding() &&
-      (FFI->hasCalls() || FFI->hasVarSizedObjects())) {
+      (FFI->hasCalls() || FFI->hasVarSizedObjects() || 
+       (RegInfo->needsStackRealignment(Fn) &&
+        FFI->getObjectIndexEnd() != 0))) {
     // If we have reserved argument space for call sites in the function
     // immediately on entry to the current function, count it as part of the
     // overall stack size.
     if (RegInfo->hasReservedCallFrame(Fn))
       Offset += FFI->getMaxCallFrameSize();
 
-    unsigned AlignMask = TFI.getStackAlignment() - 1;
+    unsigned AlignMask = std::max(TFI.getStackAlignment(),MaxAlign) - 1;
     Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
   }
 
@@ -484,14 +490,16 @@
 /// prolog and epilog code to the function.
 ///
 void PEI::insertPrologEpilogCode(MachineFunction &Fn) {
+  const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
+
   // Add prologue to the function...
-  Fn.getTarget().getRegisterInfo()->emitPrologue(Fn);
+  TRI->emitPrologue(Fn);
 
   // Add epilogue to restore the callee-save registers in each exiting block
   for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
     // If last instruction is a return instruction, add an epilogue
     if (!I->empty() && I->back().getDesc().isReturn())
-      Fn.getTarget().getRegisterInfo()->emitEpilogue(Fn, *I);
+      TRI->emitEpilogue(Fn, *I);
   }
 }
 

Modified: llvm/branches/non-call-eh/lib/CodeGen/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/README.txt?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/README.txt (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/README.txt Sun Jul  6 15:45:41 2008
@@ -197,3 +197,12 @@
 which would eliminate a bunch of explicit predicates on them (e.g. no side 
 effects).  Once this is in place, it would be even better to have tblgen 
 synthesize the various copy insertion/inspection methods in TargetInstrInfo.
+
+//===---------------------------------------------------------------------===//
+
+Stack coloring improvments:
+
+1. Do proper LiveStackAnalysis on all stack objects including those which are
+   not spill slots.
+2. Reorder objects to fill in gaps between objects.
+   e.g. 4, 1, <gap>, 4, 1, 1, 1, <gap>, 4 => 4, 1, 1, 1, 1, 4, 4

Modified: llvm/branches/non-call-eh/lib/CodeGen/RegAllocBigBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/RegAllocBigBlock.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/RegAllocBigBlock.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/RegAllocBigBlock.cpp Sun Jul  6 15:45:41 2008
@@ -52,11 +52,11 @@
 STATISTIC(NumLoads , "Number of loads added");
 STATISTIC(NumFolded, "Number of loads/stores folded into instructions");
 
-namespace {
-  static RegisterRegAlloc
-    bigBlockRegAlloc("bigblock", "  Big-block register allocator",
-                  createBigBlockRegisterAllocator);
+static RegisterRegAlloc
+  bigBlockRegAlloc("bigblock", "  Big-block register allocator",
+                createBigBlockRegisterAllocator);
 
+namespace {
 /// VRegKeyInfo - Defines magic values required to use VirtRegs as DenseMap
 /// keys.
   struct VRegKeyInfo {

Modified: llvm/branches/non-call-eh/lib/CodeGen/RegAllocLinearScan.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/RegAllocLinearScan.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/RegAllocLinearScan.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/RegAllocLinearScan.cpp Sun Jul  6 15:45:41 2008
@@ -12,10 +12,11 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "regalloc"
-#include "llvm/CodeGen/LiveIntervalAnalysis.h"
 #include "PhysRegTracker.h"
 #include "VirtRegMap.h"
 #include "llvm/Function.h"
+#include "llvm/CodeGen/LiveIntervalAnalysis.h"
+#include "llvm/CodeGen/LiveStackAnalysis.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
@@ -42,6 +43,11 @@
 STATISTIC(NumBacktracks, "Number of times we had to backtrack");
 STATISTIC(NumCoalesce,   "Number of copies coalesced");
 
+static cl::opt<bool>
+NewHeuristic("new-spilling-heuristic",
+             cl::desc("Use new spilling heuristic"),
+             cl::init(false), cl::Hidden);
+
 static RegisterRegAlloc
 linearscanRegAlloc("linearscan", "  linear scan register allocator",
                    createLinearScanRegisterAllocator);
@@ -61,12 +67,14 @@
     std::map<unsigned, const TargetRegisterClass*> OneClassForEachPhysReg;
 
     MachineFunction* mf_;
+    MachineRegisterInfo* mri_;
     const TargetMachine* tm_;
     const TargetRegisterInfo* tri_;
     const TargetInstrInfo* tii_;
     MachineRegisterInfo *reginfo_;
     BitVector allocatableRegs_;
     LiveIntervals* li_;
+    LiveStacks* ls_;
     const MachineLoopInfo *loopInfo;
 
     /// handled_ - Intervals are added to the handled_ set in the order of their
@@ -103,6 +111,8 @@
       // Make sure PassManager knows which analyses to make available
       // to coalescing and which analyses coalescing invalidates.
       AU.addRequiredTransitive<RegisterCoalescer>();
+      AU.addRequired<LiveStacks>();
+      AU.addPreserved<LiveStacks>();
       AU.addRequired<MachineLoopInfo>();
       AU.addPreserved<MachineLoopInfo>();
       AU.addPreservedID(MachineDominatorsID);
@@ -132,6 +142,15 @@
     /// is available, or spill.
     void assignRegOrStackSlotAtInterval(LiveInterval* cur);
 
+    /// findIntervalsToSpill - Determine the intervals to spill for the
+    /// specified interval. It's passed the physical registers whose spill
+    /// weight is the lowest among all the registers whose live intervals
+    /// conflict with the interval.
+    void findIntervalsToSpill(LiveInterval *cur,
+                            std::vector<std::pair<unsigned,float> > &Candidates,
+                            unsigned NumCands,
+                            SmallVector<LiveInterval*, 8> &SpillIntervals);
+
     /// attemptTrivialCoalescing - If a simple interval is defined by a copy,
     /// try allocate the definition the same register as the source register
     /// if the register is not defined during live time of the interval. This
@@ -171,6 +190,9 @@
   char RALinScan::ID = 0;
 }
 
+static RegisterPass<RALinScan>
+X("linearscan-regalloc", "Linear Scan Register Allocator");
+
 void RALinScan::ComputeRelatedRegClasses() {
   const TargetRegisterInfo &TRI = *tri_;
   
@@ -252,12 +274,14 @@
 
 bool RALinScan::runOnMachineFunction(MachineFunction &fn) {
   mf_ = &fn;
+  mri_ = &fn.getRegInfo();
   tm_ = &fn.getTarget();
   tri_ = tm_->getRegisterInfo();
   tii_ = tm_->getInstrInfo();
   reginfo_ = &mf_->getRegInfo();
   allocatableRegs_ = tri_->getAllocatableSet(fn);
   li_ = &getAnalysis<LiveIntervals>();
+  ls_ = &getAnalysis<LiveStacks>();
   loopInfo = &getAnalysis<MachineLoopInfo>();
 
   // We don't run the coalescer here because we have no reason to
@@ -281,7 +305,7 @@
   spiller_->runOnMachineFunction(*mf_, *vrm_);
   vrm_.reset();  // Free the VirtRegMap
 
-  while (!unhandled_.empty()) unhandled_.pop();
+  assert(unhandled_.empty() && "Unhandled live intervals remain!");
   fixed_.clear();
   active_.clear();
   inactive_.clear();
@@ -504,6 +528,129 @@
   }
 }
 
+/// addStackInterval - Create a LiveInterval for stack if the specified live
+/// interval has been spilled.
+static void addStackInterval(LiveInterval *cur, LiveStacks *ls_,
+                             LiveIntervals *li_, float &Weight,
+                             VirtRegMap &vrm_) {
+  int SS = vrm_.getStackSlot(cur->reg);
+  if (SS == VirtRegMap::NO_STACK_SLOT)
+    return;
+  LiveInterval &SI = ls_->getOrCreateInterval(SS);
+  SI.weight += Weight;
+
+  VNInfo *VNI;
+  if (SI.getNumValNums())
+    VNI = SI.getValNumInfo(0);
+  else
+    VNI = SI.getNextValue(~0U, 0, ls_->getVNInfoAllocator());
+
+  LiveInterval &RI = li_->getInterval(cur->reg);
+  // FIXME: This may be overly conservative.
+  SI.MergeRangesInAsValue(RI, VNI);
+}
+
+/// getConflictWeight - Return the number of conflicts between cur
+/// live interval and defs and uses of Reg weighted by loop depthes.
+static float getConflictWeight(LiveInterval *cur, unsigned Reg,
+                                  LiveIntervals *li_,
+                                  MachineRegisterInfo *mri_,
+                                  const MachineLoopInfo *loopInfo) {
+  float Conflicts = 0;
+  for (MachineRegisterInfo::reg_iterator I = mri_->reg_begin(Reg),
+         E = mri_->reg_end(); I != E; ++I) {
+    MachineInstr *MI = &*I;
+    if (cur->liveAt(li_->getInstructionIndex(MI))) {
+      unsigned loopDepth = loopInfo->getLoopDepth(MI->getParent());
+      Conflicts += powf(10.0f, (float)loopDepth);
+    }
+  }
+  return Conflicts;
+}
+
+/// findIntervalsToSpill - Determine the intervals to spill for the
+/// specified interval. It's passed the physical registers whose spill
+/// weight is the lowest among all the registers whose live intervals
+/// conflict with the interval.
+void RALinScan::findIntervalsToSpill(LiveInterval *cur,
+                            std::vector<std::pair<unsigned,float> > &Candidates,
+                            unsigned NumCands,
+                            SmallVector<LiveInterval*, 8> &SpillIntervals) {
+  // We have figured out the *best* register to spill. But there are other
+  // registers that are pretty good as well (spill weight within 3%). Spill
+  // the one that has fewest defs and uses that conflict with cur.
+  float Conflicts[3] = { 0.0f, 0.0f, 0.0f };
+  SmallVector<LiveInterval*, 8> SLIs[3];
+
+  DOUT << "\tConsidering " << NumCands << " candidates: ";
+  DEBUG(for (unsigned i = 0; i != NumCands; ++i)
+          DOUT << tri_->getName(Candidates[i].first) << " ";
+        DOUT << "\n";);
+  
+  // Calculate the number of conflicts of each candidate.
+  for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) {
+    unsigned Reg = i->first->reg;
+    unsigned PhysReg = vrm_->getPhys(Reg);
+    if (!cur->overlapsFrom(*i->first, i->second))
+      continue;
+    for (unsigned j = 0; j < NumCands; ++j) {
+      unsigned Candidate = Candidates[j].first;
+      if (tri_->regsOverlap(PhysReg, Candidate)) {
+        if (NumCands > 1)
+          Conflicts[j] += getConflictWeight(cur, Reg, li_, mri_, loopInfo);
+        SLIs[j].push_back(i->first);
+      }
+    }
+  }
+
+  for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end(); ++i){
+    unsigned Reg = i->first->reg;
+    unsigned PhysReg = vrm_->getPhys(Reg);
+    if (!cur->overlapsFrom(*i->first, i->second-1))
+      continue;
+    for (unsigned j = 0; j < NumCands; ++j) {
+      unsigned Candidate = Candidates[j].first;
+      if (tri_->regsOverlap(PhysReg, Candidate)) {
+        if (NumCands > 1)
+          Conflicts[j] += getConflictWeight(cur, Reg, li_, mri_, loopInfo);
+        SLIs[j].push_back(i->first);
+      }
+    }
+  }
+
+  // Which is the best candidate?
+  unsigned BestCandidate = 0;
+  float MinConflicts = Conflicts[0];
+  for (unsigned i = 1; i != NumCands; ++i) {
+    if (Conflicts[i] < MinConflicts) {
+      BestCandidate = i;
+      MinConflicts = Conflicts[i];
+    }
+  }
+
+  std::copy(SLIs[BestCandidate].begin(), SLIs[BestCandidate].end(),
+            std::back_inserter(SpillIntervals));
+}
+
+namespace {
+  struct WeightCompare {
+    typedef std::pair<unsigned, float> RegWeightPair;
+    bool operator()(const RegWeightPair &LHS, const RegWeightPair &RHS) const {
+      return LHS.second < RHS.second;
+    }
+  };
+}
+
+static bool weightsAreClose(float w1, float w2) {
+  if (!NewHeuristic)
+    return false;
+
+  float diff = w1 - w2;
+  if (diff <= 0.02f)  // Within 0.02f
+    return true;
+  return (diff / w2) <= 0.05f;  // Within 5%.
+}
+
 /// assignRegOrStackSlotAtInterval - assign a register if one is available, or
 /// spill.
 void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
@@ -652,7 +799,7 @@
   DOUT << "no free registers\n";
 
   // Compile the spill weights into an array that is better for scanning.
-  std::vector<float> SpillWeights(tri_->getNumRegs(), 0.0);
+  std::vector<float> SpillWeights(tri_->getNumRegs(), 0.0f);
   for (std::vector<std::pair<unsigned, float> >::iterator
        I = SpillWeightsToAdd.begin(), E = SpillWeightsToAdd.end(); I != E; ++I)
     updateSpillWeights(SpillWeights, I->first, I->second, tri_);
@@ -671,52 +818,66 @@
 
   // Find a register to spill.
   float minWeight = HUGE_VALF;
-  unsigned minReg = cur->preference;  // Try the preferred register first.
-  
+  unsigned minReg = 0; /*cur->preference*/;  // Try the preferred register first.
+
+  bool Found = false;
+  std::vector<std::pair<unsigned,float> > RegsWeights;
   if (!minReg || SpillWeights[minReg] == HUGE_VALF)
     for (TargetRegisterClass::iterator i = RC->allocation_order_begin(*mf_),
            e = RC->allocation_order_end(*mf_); i != e; ++i) {
       unsigned reg = *i;
-      if (minWeight > SpillWeights[reg]) {
-        minWeight = SpillWeights[reg];
-        minReg = reg;
-      }
+      float regWeight = SpillWeights[reg];
+      if (minWeight > regWeight)
+        Found = true;
+      RegsWeights.push_back(std::make_pair(reg, regWeight));
     }
   
   // If we didn't find a register that is spillable, try aliases?
-  if (!minReg) {
+  if (!Found) {
     for (TargetRegisterClass::iterator i = RC->allocation_order_begin(*mf_),
            e = RC->allocation_order_end(*mf_); i != e; ++i) {
       unsigned reg = *i;
       // No need to worry about if the alias register size < regsize of RC.
       // We are going to spill all registers that alias it anyway.
-      for (const unsigned* as = tri_->getAliasSet(reg); *as; ++as) {
-        if (minWeight > SpillWeights[*as]) {
-          minWeight = SpillWeights[*as];
-          minReg = *as;
-        }
-      }
+      for (const unsigned* as = tri_->getAliasSet(reg); *as; ++as)
+        RegsWeights.push_back(std::make_pair(*as, SpillWeights[*as]));
     }
+  }
 
+  // Sort all potential spill candidates by weight.
+  std::sort(RegsWeights.begin(), RegsWeights.end(), WeightCompare());
+  minReg = RegsWeights[0].first;
+  minWeight = RegsWeights[0].second;
+  if (minWeight == HUGE_VALF) {
     // All registers must have inf weight. Just grab one!
-    if (!minReg) {
-        minReg = BestPhysReg ? BestPhysReg : *RC->allocation_order_begin(*mf_);
-        if (cur->weight == HUGE_VALF || cur->getSize() == 1)
-          // Spill a physical register around defs and uses.
-          li_->spillPhysRegAroundRegDefsUses(*cur, minReg, *vrm_);
-    }
+    minReg = BestPhysReg ? BestPhysReg : *RC->allocation_order_begin(*mf_);
+    if (cur->weight == HUGE_VALF || cur->getSize() == 1)
+      // Spill a physical register around defs and uses.
+      li_->spillPhysRegAroundRegDefsUses(*cur, minReg, *vrm_);
   }
-  
-  DOUT << "\t\tregister with min weight: "
-       << tri_->getName(minReg) << " (" << minWeight << ")\n";
+
+  // Find up to 3 registers to consider as spill candidates.
+  unsigned LastCandidate = RegsWeights.size() >= 3 ? 3 : 1;
+  while (LastCandidate > 1) {
+    if (weightsAreClose(RegsWeights[LastCandidate-1].second, minWeight))
+      break;
+    --LastCandidate;
+  }
+
+  DOUT << "\t\tregister(s) with min weight(s): ";
+  DEBUG(for (unsigned i = 0; i != LastCandidate; ++i)
+          DOUT << tri_->getName(RegsWeights[i].first)
+               << " (" << RegsWeights[i].second << ")\n");
 
   // if the current has the minimum weight, we need to spill it and
   // add any added intervals back to unhandled, and restart
   // linearscan.
   if (cur->weight != HUGE_VALF && cur->weight <= minWeight) {
     DOUT << "\t\t\tspilling(c): " << *cur << '\n';
+    float SSWeight;
     std::vector<LiveInterval*> added =
-      li_->addIntervalsForSpills(*cur, loopInfo, *vrm_);
+      li_->addIntervalsForSpills(*cur, loopInfo, *vrm_, SSWeight);
+    addStackInterval(cur, ls_, li_, SSWeight, *vrm_);
     if (added.empty())
       return;  // Early exit if all spills were folded.
 
@@ -735,56 +896,41 @@
   // should go back right in the front of the list
   unhandled_.push(cur);
 
-  // otherwise we spill all intervals aliasing the register with
-  // minimum weight, rollback to the interval with the earliest
-  // start point and let the linear scan algorithm run again
-  std::vector<LiveInterval*> added;
   assert(TargetRegisterInfo::isPhysicalRegister(minReg) &&
          "did not choose a register to spill?");
-  BitVector toSpill(tri_->getNumRegs());
 
-  // We are going to spill minReg and all its aliases.
-  toSpill[minReg] = true;
-  for (const unsigned* as = tri_->getAliasSet(minReg); *as; ++as)
-    toSpill[*as] = true;
+  // We spill all intervals aliasing the register with
+  // minimum weight, rollback to the interval with the earliest
+  // start point and let the linear scan algorithm run again
+  SmallVector<LiveInterval*, 8> spillIs;
 
-  // the earliest start of a spilled interval indicates up to where
+  // Determine which intervals have to be spilled.
+  findIntervalsToSpill(cur, RegsWeights, LastCandidate, spillIs);
+
+  // Set of spilled vregs (used later to rollback properly)
+  SmallSet<unsigned, 8> spilled;
+
+  // The earliest start of a Spilled interval indicates up to where
   // in handled we need to roll back
   unsigned earliestStart = cur->beginNumber();
 
-  // set of spilled vregs (used later to rollback properly)
-  SmallSet<unsigned, 32> spilled;
-
-  // spill live intervals of virtual regs mapped to the physical register we
+  // Spill live intervals of virtual regs mapped to the physical register we
   // want to clear (and its aliases).  We only spill those that overlap with the
   // current interval as the rest do not affect its allocation. we also keep
   // track of the earliest start of all spilled live intervals since this will
   // mark our rollback point.
-  for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) {
-    unsigned reg = i->first->reg;
-    if (//TargetRegisterInfo::isVirtualRegister(reg) &&
-        toSpill[vrm_->getPhys(reg)] &&
-        cur->overlapsFrom(*i->first, i->second)) {
-      DOUT << "\t\t\tspilling(a): " << *i->first << '\n';
-      earliestStart = std::min(earliestStart, i->first->beginNumber());
-      std::vector<LiveInterval*> newIs =
-        li_->addIntervalsForSpills(*i->first, loopInfo, *vrm_);
-      std::copy(newIs.begin(), newIs.end(), std::back_inserter(added));
-      spilled.insert(reg);
-    }
-  }
-  for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end(); ++i){
-    unsigned reg = i->first->reg;
-    if (//TargetRegisterInfo::isVirtualRegister(reg) &&
-        toSpill[vrm_->getPhys(reg)] &&
-        cur->overlapsFrom(*i->first, i->second-1)) {
-      DOUT << "\t\t\tspilling(i): " << *i->first << '\n';
-      earliestStart = std::min(earliestStart, i->first->beginNumber());
-      std::vector<LiveInterval*> newIs =
-        li_->addIntervalsForSpills(*i->first, loopInfo, *vrm_);
-      std::copy(newIs.begin(), newIs.end(), std::back_inserter(added));
-      spilled.insert(reg);
-    }
+  std::vector<LiveInterval*> added;
+  while (!spillIs.empty()) {
+    LiveInterval *sli = spillIs.back();
+    spillIs.pop_back();
+    DOUT << "\t\t\tspilling(a): " << *sli << '\n';
+    earliestStart = std::min(earliestStart, sli->beginNumber());
+    float SSWeight;
+    std::vector<LiveInterval*> newIs =
+      li_->addIntervalsForSpills(*sli, loopInfo, *vrm_, SSWeight);
+    addStackInterval(sli, ls_, li_, SSWeight, *vrm_);
+    std::copy(newIs.begin(), newIs.end(), std::back_inserter(added));
+    spilled.insert(sli->reg);
   }
 
   DOUT << "\t\trolling back to: " << earliestStart << '\n';

Modified: llvm/branches/non-call-eh/lib/CodeGen/RegAllocLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/RegAllocLocal.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/RegAllocLocal.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/RegAllocLocal.cpp Sun Jul  6 15:45:41 2008
@@ -37,12 +37,11 @@
 STATISTIC(NumStores, "Number of stores added");
 STATISTIC(NumLoads , "Number of loads added");
 
-namespace {
-  static RegisterRegAlloc
-    localRegAlloc("local", "  local register allocator",
-                  createLocalRegisterAllocator);
-
+static RegisterRegAlloc
+  localRegAlloc("local", "  local register allocator",
+                createLocalRegisterAllocator);
 
+namespace {
   class VISIBILITY_HIDDEN RALocal : public MachineFunctionPass {
   public:
     static char ID;
@@ -550,10 +549,10 @@
 
   // If this is the first basic block in the machine function, add live-in
   // registers as active.
-  if (&MBB == &*MF->begin()) {
-    for (MachineRegisterInfo::livein_iterator I=MF->getRegInfo().livein_begin(),
-         E = MF->getRegInfo().livein_end(); I != E; ++I) {
-      unsigned Reg = I->first;
+  if (&MBB == &*MF->begin() || MBB.isLandingPad()) {
+    for (MachineBasicBlock::livein_iterator I = MBB.livein_begin(),
+         E = MBB.livein_end(); I != E; ++I) {
+      unsigned Reg = *I;
       MF->getRegInfo().setPhysRegUsed(Reg);
       PhysRegsUsed[Reg] = 0;            // It is free and reserved now
       AddToPhysRegsUseOrder(Reg); 

Modified: llvm/branches/non-call-eh/lib/CodeGen/RegisterCoalescer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/RegisterCoalescer.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/RegisterCoalescer.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/RegisterCoalescer.cpp Sun Jul  6 15:45:41 2008
@@ -22,9 +22,7 @@
 using namespace llvm;
 
 // Register the RegisterCoalescer interface, providing a nice name to refer to.
-namespace {
-  RegisterAnalysisGroup<RegisterCoalescer> Z("Register Coalescer");
-}
+static RegisterAnalysisGroup<RegisterCoalescer> Z("Register Coalescer");
 char RegisterCoalescer::ID = 0;
 
 // RegisterCoalescer destructor: DO NOT move this to the header file

Modified: llvm/branches/non-call-eh/lib/CodeGen/RegisterScavenging.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/RegisterScavenging.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/RegisterScavenging.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/RegisterScavenging.cpp Sun Jul  6 15:45:41 2008
@@ -37,11 +37,12 @@
     const MachineOperand &MO = MI->getOperand(i);
     if (!MO.isRegister())
       continue;
-    if (TRI->isSuperRegister(SubReg, MO.getReg()))
+    if (TRI->isSuperRegister(SubReg, MO.getReg())) {
       if (MO.isUse())
         SeenSuperUse = true;
       else if (MO.isImplicit())
         SeenSuperDef = true;
+    }
   }
 
   return SeenSuperDef && SeenSuperUse;

Modified: llvm/branches/non-call-eh/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/non-call-eh/lib/CodeGen/SelectionDAG/CallingConvLower.cpp?rev=53163&r1=53162&r2=53163&view=diff

==============================================================================
--- llvm/branches/non-call-eh/lib/CodeGen/SelectionDAG/CallingConvLower.cpp (original)
+++ llvm/branches/non-call-eh/lib/CodeGen/SelectionDAG/CallingConvLower.cpp Sun Jul  6 15:45:41 2008
@@ -26,14 +26,14 @@
   // No stack is used.
   StackOffset = 0;
   
-  UsedRegs.resize(TRI.getNumRegs());
+  UsedRegs.resize((TRI.getNumRegs()+31)/32);
 }
 
 // HandleByVal - Allocate a stack slot large enough to pass an argument by
 // value. The size and alignment information of the argument is encoded in its
 // parameter attribute.
-void CCState::HandleByVal(unsigned ValNo, MVT::ValueType ValVT,
-                          MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
+void CCState::HandleByVal(unsigned ValNo, MVT ValVT,
+                          MVT LocVT, CCValAssign::LocInfo LocInfo,
                           int MinSize, int MinAlign,
                           ISD::ArgFlagsTy ArgFlags) {
   unsigned Align = ArgFlags.getByValAlign();
@@ -62,12 +62,12 @@
   unsigned NumArgs = TheArgs->getNumValues()-1;
   
   for (unsigned i = 0; i != NumArgs; ++i) {
-    MVT::ValueType ArgVT = TheArgs->getValueType(i);
+    MVT ArgVT = TheArgs->getValueType(i);
     ISD::ArgFlagsTy ArgFlags =
       cast<ARG_FLAGSSDNode>(TheArgs->getOperand(3+i))->getArgFlags();
     if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
       cerr << "Formal argument #" << i << " has unhandled type "
-           << MVT::getValueTypeString(ArgVT) << "\n";
+           << ArgVT.getMVTString() << "\n";
       abort();
     }
   }
@@ -78,12 +78,12 @@
 void CCState::AnalyzeReturn(SDNode *TheRet, CCAssignFn Fn) {
   // Determine which register each value should be copied into.
   for (unsigned i = 0, e = TheRet->getNumOperands() / 2; i != e; ++i) {
-    MVT::ValueType VT = TheRet->getOperand(i*2+1).getValueType();
+    MVT VT = TheRet->getOperand(i*2+1).getValueType();
     ISD::ArgFlagsTy ArgFlags =
       cast<ARG_FLAGSSDNode>(TheRet->getOperand(i*2+2))->getArgFlags();
     if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)){
       cerr << "Return operand #" << i << " has unhandled type "
-           << MVT::getValueTypeString(VT) << "\n";
+           << VT.getMVTString() << "\n";
       abort();
     }
   }
@@ -95,12 +95,12 @@
 void CCState::AnalyzeCallOperands(SDNode *TheCall, CCAssignFn Fn) {
   unsigned NumOps = (TheCall->getNumOperands() - 5) / 2;
   for (unsigned i = 0; i != NumOps; ++i) {
-    MVT::ValueType ArgVT = TheCall->getOperand(5+2*i).getValueType();
+    MVT ArgVT = TheCall->getOperand(5+2*i).getValueType();
     ISD::ArgFlagsTy ArgFlags =
       cast<ARG_FLAGSSDNode>(TheCall->getOperand(5+2*i+1))->getArgFlags();
     if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
       cerr << "Call operand #" << i << " has unhandled type "
-           << MVT::getValueTypeString(ArgVT) << "\n";
+           << ArgVT.getMVTString() << "\n";
       abort();
     }
   }
@@ -110,10 +110,10 @@
 /// incorporating info about the passed values into this state.
 void CCState::AnalyzeCallResult(SDNode *TheCall, CCAssignFn Fn) {
   for (unsigned i = 0, e = TheCall->getNumValues() - 1; i != e; ++i) {
-    MVT::ValueType VT = TheCall->getValueType(i);
+    MVT VT = TheCall->getValueType(i);
     if (Fn(i, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) {
       cerr << "Call result #" << i << " has unhandled type "
-           << MVT::getValueTypeString(VT) << "\n";
+           << VT.getMVTString() << "\n";
       abort();
     }
   }





More information about the llvm-commits mailing list