aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Law <law@gcc.gnu.org>1994-11-10 23:11:14 -0700
committerJeff Law <law@gcc.gnu.org>1994-11-10 23:11:14 -0700
commita205e34b227a13e890ab1071f956799906cfe689 (patch)
tree46dcb01ad5a837cd944e0ef39ec1baf041f8b87f
parent279c9bde625781e47709a2a5900c3c56966e67e7 (diff)
downloadgcc-a205e34b227a13e890ab1071f956799906cfe689.zip
gcc-a205e34b227a13e890ab1071f956799906cfe689.tar.gz
gcc-a205e34b227a13e890ab1071f956799906cfe689.tar.bz2
Jeff for Tege:
* pa.h (GO_IF_LEGITIMATE_ADDRESS): Allow (lo_sum (reg) (unspec (symref))). * pa.md (pic2_lo_sum): New pattern matching when -fPIC using UNSPEC. * pa.c (legitimize_pic_address): Generate an insn matching pic2_lo_sum when -fPIC. * pa.md (pic_highpart): Add missing mode for PLUS. (add_high_const): Likewise. * pa.md (matcher for plain lo_sum): Call abort if this happens when generating pic or PIC. From-SVN: r8423
-rw-r--r--gcc/config/pa/pa.c6
-rw-r--r--gcc/config/pa/pa.h6
-rw-r--r--gcc/config/pa/pa.md28
3 files changed, 31 insertions, 9 deletions
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index 21d207f..a458203 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -491,8 +491,10 @@ legitimize_pic_address (orig, mode, reg)
if (flag_pic == 2)
{
- emit_insn (gen_pic_highpart (reg, pic_offset_table_rtx, orig));
- pic_ref = (gen_rtx (MEM, Pmode, gen_rtx (LO_SUM, Pmode, reg, orig)));
+ emit_insn (gen_pic2_highpart (reg, pic_offset_table_rtx, orig));
+ pic_ref = gen_rtx (MEM, Pmode,
+ gen_rtx (LO_SUM, Pmode, reg,
+ gen_rtx (UNSPEC, SImode, gen_rtvec (1, orig), 0)));
}
else
pic_ref = gen_rtx (MEM, Pmode,
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index 218a97d..ceef67d7 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -1355,6 +1355,12 @@ extern union tree_node *current_function_decl;
|| (GET_CODE (X) == CONST_INT \
&& INT_5_BITS (X))) \
goto ADDR; \
+ /* Needed for -fPIC */ \
+ else if (GET_CODE (X) == LO_SUM \
+ && GET_CODE (XEXP (X, 0)) == REG \
+ && REG_OK_FOR_BASE_P (XEXP (X, 0)) \
+ && GET_CODE (XEXP (X, 1)) == UNSPEC) \
+ goto ADDR; \
}
/* Try machine-dependent ways of modifying an illegitimate address
diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index db6cf97..1917fac 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -1166,10 +1166,10 @@
[(set_attr "type" "multi")
(set_attr "length" "16")]) ; 12 or 16
-(define_insn "pic_highpart"
+(define_insn "pic2_highpart"
[(set (match_operand:SI 0 "register_operand" "=a")
- (plus (match_operand:SI 1 "register_operand" "r")
- (high:SI (match_operand 2 "" ""))))]
+ (plus:SI (match_operand:SI 1 "register_operand" "r")
+ (high:SI (match_operand 2 "" ""))))]
"symbolic_operand (operands[2], Pmode)
&& ! function_label_operand (operands[2])
&& ! read_only_operand (operands[2])
@@ -1178,6 +1178,22 @@
[(set_attr "type" "binary")
(set_attr "length" "4")])
+; We need this to make sure CSE doesn't simplify a memory load with a
+; symbolic address, whose content it think it knows. For PIC, what CSE
+; think is the real value will be the address of that value.
+(define_insn "pic2_lo_sum"
+ [(set (match_operand:SI 0 "register_operand" "=r")
+ (mem:SI (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
+ (unspec:SI [(match_operand:SI 2 "symbolic_operand" "")] 0))))]
+ ""
+ "*
+{
+ if (flag_pic != 2)
+ abort ();
+ return \"ldw RT'%G2(%1),%0\";
+}")
+
+
;; Always use addil rather than ldil;add sequences. This allows the
;; HP linker to eliminate the dp relocation if the symbolic operand
;; lives in the TEXT space.
@@ -1267,9 +1283,7 @@
"!is_function_label_plus_const (operands[2])"
"*
{
- if (flag_pic == 2 && symbolic_operand (operands[2], Pmode))
- return \"ldw RT'%G2(%1),%0\";
- else if (flag_pic == 1 && symbolic_operand (operands[2], Pmode))
+ if (flag_pic && symbolic_operand (operands[2], Pmode))
abort ();
else
return \"ldo R'%G2(%1),%0\";
@@ -1386,7 +1400,7 @@
(define_insn ""
[(set (match_operand:HI 0 "register_operand" "=r")
(lo_sum:HI (match_operand:HI 1 "register_operand" "r")
- (match_operand 2 "const_int_operand" "i")))]
+ (match_operand 2 "const_int_operand" "")))]
""
"ldo R'%G2(%1),%0"
[(set_attr "length" "4")])