diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index d209ac896fd..87f58332016 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -624,3 +624,7 @@ Enum(tls_type) String(desc) Value(TLS_DESCRIPTORS) mtls-dialect= Target RejectNegative Joined Enum(tls_type) Var(riscv_tls_dialect) Init(TLS_TRADITIONAL) Save Specify TLS dialect. + +mfence-tso +Target Var(TARGET_FENCE_TSO) Init(1) +Specifies whether the fence.tso instruction should be used. diff --git a/gcc/config/riscv/sync-rvwmo.md b/gcc/config/riscv/sync-rvwmo.md index d4fd26069f7..e639a1e2392 100644 --- a/gcc/config/riscv/sync-rvwmo.md +++ b/gcc/config/riscv/sync-rvwmo.md @@ -33,7 +33,7 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,rw"; else if (model == MEMMODEL_ACQ_REL) - return "fence.tso"; + return TARGET_FENCE_TSO ? "fence.tso" : "fence\trw,rw"; else if (model == MEMMODEL_ACQUIRE) return "fence\tr,rw"; else if (model == MEMMODEL_RELEASE) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b9408ecc918..70e8004a71b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1244,6 +1244,7 @@ See RS/6000 and PowerPC Options. -mplt -mno-plt -mabi=@var{ABI-string} -mfdiv -mno-fdiv +-mfence-tso -mno-fence-tso -mdiv -mno-div -misa-spec=@var{ISA-spec-string} -march=@var{ISA-string} @@ -30436,6 +30437,13 @@ Do or don't use hardware floating-point divide and square root instructions. This requires the F or D extensions for floating-point registers. The default is to use them if the specified architecture has these instructions. +@opindex mfence-tso +@item -mfence-tso +@itemx -mno-fence-tso +Do or don't use the @samp{fence.tso} instruction, which is unimplemented on +some processors (including those from T-Head). If the @samp{fence.tso} +instruction is not availiable then a stronger fence will be used instead. + @opindex mdiv @item -mdiv @itemx -mno-div