 -                IIC_Br, "blx\t$func",
 +// @LOCALMOD-START
 +//                IIC_Br, "blx\t$func",
-+                IIC_Br, "sfi_call_preamble\n\tblx\t$func",
++                IIC_Br, "sfi_indirect_call_preamble $func\n\tblx\t$func",
 +// @LOCALMOD-END
                  [(ARMcall GPR:$func)]>,
              Requires<[IsARM, HasV5T, IsNotDarwin]> {
      let Inst{7-4}   = 0b0011;
-@@ -701,7 +719,10 @@
+@@ -701,7 +723,11 @@
  
    // ARMv4T
    def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops),
 -                  IIC_Br, "mov\tlr, pc\n\tbx\t$func",
 +// @LOCALMOD-START
 +//                  IIC_Br, "mov\tlr, pc\n\tbx\t$func",
++// TODO(robertm): this does not quite work
 +                  IIC_Br, "sfi_call_preamble\n\tmov\tlr, pc\n\tbx\t$func",
 +// @LOCALMOD-END
                    [(ARMcall_nolink GPR:$func)]>,
             Requires<[IsARM, IsNotDarwin]> {
      let Inst{7-4}   = 0b0001;
-@@ -717,19 +738,28 @@
+@@ -717,19 +743,28 @@
            D16, D17, D18, D19, D20, D21, D22, D23,
            D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
    def BLr9  : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),

+  O << " @ ========================================\n";
+  // NOTE: this macro does bundle alignment as follows
+  //       if current bundle pos is X emit pX data items of value "val"
+  //
+  O <<
+    "\t.macro sfi_long_based_on_pos p0 p1 p2 p3 val\n"
+    "\t.set  pos, (. - XmagicX) % 16\n"
+    "\t.fill (((\\p3<<12)|(\\p2<<8)|(\\p1<<4)|\\p0)>>pos) & 15, 4, \\val\n"
+    "\t.endm\n"
+    "\n\n";
+

                []>;
 
 //===----------------------------------------------------------------------===//
@@ -1087,6 +1143,17 @@
 defm SUB  : AsI1_bin_irs<0b0010, "sub",
                          BinOpFrag<(sub  node:$LHS, node:$RHS)>>;
 
